Skip to content
Browse files

fix a bug where Cucumber::Runtime#step_match would return a StepDefin…

…ition instead of a StepMatch when ambiguous steps are present
  • Loading branch information...
1 parent ada4fd9 commit 0e1d28b0cb864bd07c574a8569a8c8c0e0119fca @henning-koch henning-koch committed Nov 17, 2010
Showing with 9 additions and 5 deletions.
  1. +5 −3 lib/cucumber/runtime_ext.rb
  2. +4 −2 spec/runtime_ext_spec.rb
View
8 lib/cucumber/runtime_ext.rb
@@ -20,9 +20,11 @@ def initialize_with_remembering_matches(step_name, matches, *args)
def step_match_with_factory_priority(*args)
step_match_without_factory_priority(*args)
rescue Ambiguous => e
- matched_definitions = e.matches.collect(&:step_definition)
- if matched_definitions.size == 2 && (Cucumber::Factory.step_definitions & matched_definitions).any?
- (matched_definitions - Cucumber::Factory.step_definitions).first
+ non_factory_matches = e.matches.reject do |match|
+ Cucumber::Factory.step_definitions.include?(match.step_definition)
+ end
+ if non_factory_matches.size == 1
+ non_factory_matches.first
else
raise
end
View
6 spec/runtime_ext_spec.rb
@@ -11,9 +11,11 @@
describe 'step_match' do
- it "should not raise an ambiguous step error and return the user step if the only other matching step is a factory step" do
+ it "should not raise an ambiguous step error and match the user step if the only other matching step is a factory step" do
user_step = @main.Given(/^there is a movie with a funny tone/){}
- @runtime.step_match('there is a movie with a funny tone').should == user_step
+ match = @runtime.step_match('there is a movie with a funny tone')
+ match.step_definition.should == user_step
+ match.should be_a(Cucumber::StepMatch)
end
it "should still raise an ambiguous step error if more than two non-factory steps match" do

0 comments on commit 0e1d28b

Please sign in to comment.
Something went wrong with that request. Please try again.