Skip to content

Instantly share code, notes, and snippets.

@kris-luminar
Created November 24, 2012 04:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kris-luminar/4138456 to your computer and use it in GitHub Desktop.
Save kris-luminar/4138456 to your computer and use it in GitHub Desktop.
Ambiguous match of "its name is Fred":
Feature: Puppies are very cute and everyone wants one
In order to make everyone happy
As a puppy class programmer
I want to give everyone a cute virtual puppy
Scenario: The puppy is being pet
Given we have a puppy
And its name is Fred
When we pet the puppy
Then the puppy wags its tail
Scenario: The puppy needs to go out
Given we have a puppy
And its name is Bella
When we ring the bell
And it wags its tail
Then we must take it out
And then it will not pee on the floor
class Puppy
attr_accessor :name
def initialize
end
def pet
wag
end
protected
def wag
"the puppy wags its tail"
end
end
Given /^we have a puppy$/ do
@puppy = Puppy.new
end
Given /^its name is (\w+)$/ do |arg1|
@puppy.name = arg1
@puppy.name == arg1
end
When /^we pet the puppy$/ do
@result = @puppy.pet
end
Then /^the puppy wags its tail$/ do
@result.should eq "the puppy wags its tail"
end
Given /^its name is (\w+)$/ do |arg1|
@puppy = Puppy.new
@puppy.name = arg1
@puppy.name.should eq arg1
end
When /^we ring the bell$/ do
@result = @puppy.ring_the_bell
end
When /^it wags its tail$/ do
pending # express the regexp above with the code you wish you had
end
Then /^we must take it out$/ do
pending # express the regexp above with the code you wish you had
end
Then /^then it will not pee on the floor$/ do
pending # express the regexp above with the code you wish you had
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment