Skip to content

Instantly share code, notes, and snippets.

@redsquirrel
Created January 27, 2012 03:27
Show Gist options
  • Save redsquirrel/1686813 to your computer and use it in GitHub Desktop.
Save redsquirrel/1686813 to your computer and use it in GitHub Desktop.
Here's what we worked on today...
# gem install rspec
class Dog
attr_reader :height, :distance
def initialize(cat)
@cat = cat
end
def jump!
@height = 24
end
def land!
@cat.jumped_over!
@height = 0
@distance = 36
end
def on_the_ground?
@height == 0
end
end
class Cat
def jumped_over?
@jumped_over
end
def jumped_over!
@jumped_over = true
end
end
describe "a dog jumping over a cat" do
context "a fake cat" do
before(:each) do
@cat = mock("cat")
end
it "jumps 2 feet high" do
dog = Dog.new(@cat)
dog.jump!
dog.height.should == 24
end
it "lands 3 feet forward" do
@cat.stub!(:jumped_over!)
dog = Dog.new(@cat)
dog.jump!
dog.land!
dog.should be_on_the_ground
dog.distance.should == 36
end
end
context "with a real cat" do
it "doesn't hit the cat" do
# pending('i like hitting cats')
# cat = mock("cat")
# cat.should_receive(:jumping_over_you)
cat = Cat.new
dog = Dog.new(cat)
dog.jump!
dog.land!
cat.should be_jumped_over
end
end
describe "when the cat is also jumping" do
it "foo" do
# [1, 2, 4].should include(3)
end
end
describe "when the cat is dead" do
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment