Skip to content

Commit

Permalink
Validate the before hook order as well
Browse files Browse the repository at this point in the history
  • Loading branch information
erran committed Sep 17, 2014
1 parent c5779e1 commit c0ce595
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions spec/cucumber/core/test/mapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,17 @@ def test_step(test_step, mapper)
it "adds hooks in the right order" do
log = double
allow(mappings).to receive(:test_case) do |test_case, mapper|
mapper.before { log.before_hook }
mapper.before { log.before_hook_1 }
mapper.before { log.before_hook_2 }
mapper.after { log.after_hook_1 }
mapper.after { log.after_hook_2 }
end
mapped_step = test_step.with_mapping { log.step }
mapped_step = test_step.with_mapping { log.step_1 }
test_case = Case.new([mapped_step], source)

expect( log ).to receive(:before_hook).ordered
expect( log ).to receive(:step).ordered
expect( log ).to receive(:before_hook_1).ordered
expect( log ).to receive(:before_hook_2).ordered
expect( log ).to receive(:step_1).ordered
expect( log ).to receive(:after_hook_2).ordered
expect( log ).to receive(:after_hook_1).ordered

Expand All @@ -130,7 +132,7 @@ def test_step(test_step, mapper)
expect( scenario ).to receive(:describe_to)
expect( visitor ).to receive(:before_hook) do |hook, hook_args|
expect( args ).to eq(hook_args)
expect( hook.location.to_s ).to eq("#{__FILE__}:123")
expect( hook.location.to_s ).to eq("#{__FILE__}:125")
end
test_step.describe_source_to(visitor, args)
end
Expand All @@ -150,7 +152,7 @@ def test_step(test_step, mapper)
expect( scenario ).to receive(:describe_to)
expect( visitor ).to receive(:after_hook) do |hook, hook_args|
expect( args ).to eq(hook_args)
expect( hook.location.to_s ).to eq("#{__FILE__}:143")
expect( hook.location.to_s ).to eq("#{__FILE__}:145")
end
test_step.describe_source_to(visitor, args)
end
Expand All @@ -170,7 +172,7 @@ def test_step(test_step, mapper)
expect( visitor ).to receive(:step).ordered
expect( visitor ).to receive(:after_step_hook) do |hook, hook_args|
expect( args ).to eq(hook_args)
expect( hook.location.to_s ).to eq("#{__FILE__}:162")
expect( hook.location.to_s ).to eq("#{__FILE__}:164")
end.once.ordered
expect( visitor ).to receive(:step).ordered
test_case.describe_to mapper
Expand Down

0 comments on commit c0ce595

Please sign in to comment.