diff --git a/spec/helpers/errored_example.cr b/spec/helpers/errored_example.cr index f535ba7..7fec2e4 100644 --- a/spec/helpers/errored_example.cr +++ b/spec/helpers/errored_example.cr @@ -10,6 +10,11 @@ class ErroredExample < Spectator::RunnableExample ::Spectator::Source.new(__FILE__, __LINE__) end + # Dummy symbolic flag. + def symbolic? + false + end + # Dummy instance. def instance nil diff --git a/spec/helpers/failing_example.cr b/spec/helpers/failing_example.cr index 76792c5..a084cc7 100644 --- a/spec/helpers/failing_example.cr +++ b/spec/helpers/failing_example.cr @@ -10,6 +10,11 @@ class FailingExample < Spectator::RunnableExample ::Spectator::Source.new(__FILE__, __LINE__) end + # Dummy symbolic flag. + def symbolic? + false + end + # Dummy instance. def instance nil diff --git a/spec/helpers/passing_example.cr b/spec/helpers/passing_example.cr index dcd0a60..80a2884 100644 --- a/spec/helpers/passing_example.cr +++ b/spec/helpers/passing_example.cr @@ -10,6 +10,11 @@ class PassingExample < Spectator::RunnableExample ::Spectator::Source.new(__FILE__, __LINE__) end + # Dummy symbolic flag. + def symbolic? + false + end + # Dummy instance. def instance nil diff --git a/spec/helpers/spy_example.cr b/spec/helpers/spy_example.cr index 66e4338..70c256a 100644 --- a/spec/helpers/spy_example.cr +++ b/spec/helpers/spy_example.cr @@ -11,6 +11,11 @@ class SpyExample < Spectator::RunnableExample ::Spectator::Source.new(__FILE__, __LINE__) end + # Dummy symbolic flag. + def symbolic? + false + end + # Dummy instance. def instance nil diff --git a/spec/nested_example_group_spec.cr b/spec/nested_example_group_spec.cr index 26ee7d9..0345328 100644 --- a/spec/nested_example_group_spec.cr +++ b/spec/nested_example_group_spec.cr @@ -1,8 +1,8 @@ require "./spec_helper" -def new_nested_group(hooks = Spectator::ExampleHooks.empty, conditions = Spectator::ExampleConditions.empty, parent : Spectator::ExampleGroup? = nil) +def new_nested_group(what : Symbol | String = "what", hooks = Spectator::ExampleHooks.empty, conditions = Spectator::ExampleConditions.empty, parent : Spectator::ExampleGroup? = nil) parent ||= Spectator::RootExampleGroup.new(Spectator::ExampleHooks.empty, Spectator::ExampleConditions.empty) - Spectator::NestedExampleGroup.new("what", parent, hooks, conditions).tap do |group| + Spectator::NestedExampleGroup.new(what, parent, hooks, conditions).tap do |group| parent.children = [group.as(Spectator::ExampleComponent)] group.children = [] of Spectator::ExampleComponent end @@ -93,7 +93,7 @@ describe Spectator::NestedExampleGroup do it "runs a single before_all hook" do called = false hooks = new_hooks(before_all: ->{ called = true; nil }) - group = new_nested_group(hooks) + group = new_nested_group(hooks: hooks) group.run_before_hooks called.should be_true end @@ -101,7 +101,7 @@ describe Spectator::NestedExampleGroup do it "runs a single before_each hook" do called = false hooks = new_hooks(before_each: ->{ called = true; nil }) - group = new_nested_group(hooks) + group = new_nested_group(hooks: hooks) group.run_before_hooks called.should be_true end @@ -113,7 +113,7 @@ describe Spectator::NestedExampleGroup do ->{ call_count += 2; nil }, ->{ call_count += 3; nil }, ]) - group = new_nested_group(hooks) + group = new_nested_group(hooks: hooks) group.run_before_hooks call_count.should eq(6) end @@ -125,7 +125,7 @@ describe Spectator::NestedExampleGroup do ->{ call_count += 2; nil }, ->{ call_count += 3; nil }, ]) - group = new_nested_group(hooks) + group = new_nested_group(hooks: hooks) group.run_before_hooks call_count.should eq(6) end @@ -142,7 +142,7 @@ describe Spectator::NestedExampleGroup do ->{ calls << :e; nil }, ->{ calls << :f; nil }, ]) - group = new_nested_group(hooks) + group = new_nested_group(hooks: hooks) group.run_before_hooks calls.should eq(%i[a b c d e f]) end @@ -443,7 +443,7 @@ describe Spectator::NestedExampleGroup do it "wraps a proc" do called = false hooks = new_hooks(around_each: ->(proc : ->) { called = true; proc.call }) - wrapper = new_nested_group(hooks).wrap_around_each_hooks { } + wrapper = new_nested_group(hooks: hooks).wrap_around_each_hooks { } wrapper.call called.should be_true end @@ -455,7 +455,7 @@ describe Spectator::NestedExampleGroup do ->(proc : ->) { call_count += 2; proc.call }, ->(proc : ->) { call_count += 3; proc.call }, ]) - wrapper = new_nested_group(hooks).wrap_around_each_hooks { } + wrapper = new_nested_group(hooks: hooks).wrap_around_each_hooks { } wrapper.call call_count.should eq(6) end @@ -467,7 +467,7 @@ describe Spectator::NestedExampleGroup do ->(proc : ->) { calls << :b; proc.call }, ->(proc : ->) { calls << :c; proc.call }, ]) - wrapper = new_nested_group(hooks).wrap_around_each_hooks { } + wrapper = new_nested_group(hooks: hooks).wrap_around_each_hooks { } wrapper.call calls.should eq(%i[a b c]) end @@ -618,7 +618,7 @@ describe Spectator::NestedExampleGroup do describe "#to_s" do it "contains #what" do group = new_nested_group - group.to_s.should contain(group.what) + group.to_s.should contain(group.what.to_s) end it "contains the parent's #to_s" do @@ -1043,4 +1043,18 @@ describe Spectator::NestedExampleGroup do end end end + + describe "#symbolic?" do + context "when 'what' is a Symbol" do + it "is true" do + new_nested_group(:What).symbolic?.should be_true + end + end + + context "when 'what' is a String" do + it "is false" do + new_nested_group("what").symbolic?.should be_false + end + end + end end diff --git a/spec/pending_example_spec.cr b/spec/pending_example_spec.cr index 9ea1a51..6809816 100644 --- a/spec/pending_example_spec.cr +++ b/spec/pending_example_spec.cr @@ -9,6 +9,10 @@ class ConcretePendingExample < Spectator::PendingExample ::Spectator::Source.new(__FILE__, __LINE__) end + def symbolic? + false + end + def instance nil end @@ -112,7 +116,7 @@ describe Spectator::PendingExample do it "contains the group's #what" do group = new_nested_group example = new_pending_example(group) - example.to_s.should contain(group.what) + example.to_s.should contain(group.what.to_s) end end end diff --git a/spec/root_example_group_spec.cr b/spec/root_example_group_spec.cr index 134ec13..c0528a9 100644 --- a/spec/root_example_group_spec.cr +++ b/spec/root_example_group_spec.cr @@ -801,4 +801,10 @@ describe Spectator::RootExampleGroup do end end end + + describe "#symbolic?" do + it "is true" do + new_root_group.symbolic?.should be_true + end + end end diff --git a/spec/runnable_example_spec.cr b/spec/runnable_example_spec.cr index 6535e76..8d28bcb 100644 --- a/spec/runnable_example_spec.cr +++ b/spec/runnable_example_spec.cr @@ -1510,7 +1510,7 @@ describe Spectator::RunnableExample do group = Spectator::NestedExampleGroup.new("the parent", root, Spectator::ExampleHooks.empty, Spectator::ExampleConditions.empty) root.children = [group.as(Spectator::ExampleComponent)] example = new_runnable_example(group) - example.to_s.should contain(group.what) + example.to_s.should contain(group.what.to_s) end end end