Skip to content

Instantly share code, notes, and snippets.

@joshski
Created June 20, 2011 16:11
Show Gist options
  • Save joshski/1035903 to your computer and use it in GitHub Desktop.
Save joshski/1035903 to your computer and use it in GitHub Desktop.
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
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