Created
June 20, 2011 16:11
-
-
Save joshski/1035903 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Anaphora | |
Scenario: Dog barks at cat | |
Given there is a dog | |
And there is a cat | |
When the dog barks at the cat | |
Then the cat should run away |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dog | |
def barks_at(subject) | |
subject.run_away! | |
end | |
end | |
class Cat | |
def run_away! | |
@ran_away = true | |
end | |
def has_run_away? | |
@ran_away || false | |
end | |
end | |
module DogWorld | |
def the_dog | |
@dog ||= Dog.new | |
end | |
end | |
module CatWorld | |
def the_cat | |
@cat ||= Cat.new | |
end | |
end | |
Given /^there is a dog$/ do | |
extend DogWorld | |
end | |
Given /^there is a cat$/ do | |
extend CatWorld | |
end | |
When /^the dog barks at the cat$/ do | |
the_dog.barks_at(the_cat) | |
end | |
Then /^the cat should run away$/ do | |
the_cat.should have_run_away | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment