From 3a7e765f24311c6b345f87f53e75bd24b57ba6ec Mon Sep 17 00:00:00 2001 From: Daniel Estrada Date: Tue, 8 May 2012 19:57:29 -0400 Subject: [PATCH] Feature: Humans eating at Zoo --- Gemfile.lock | 1 + zoo.rb | 14 ++++++++++++++ zoo_spec.rb | 27 +++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index 277fb87..8b2355e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,6 +14,7 @@ GEM PLATFORMS ruby + x86-mingw32 DEPENDENCIES rake diff --git a/zoo.rb b/zoo.rb index 8f5eea5..866f188 100644 --- a/zoo.rb +++ b/zoo.rb @@ -52,6 +52,20 @@ def full? end end + +class Human + include Animal + + def acceptable_food + [:bacon, :tacos] + end + + def full? + @meals > 2 + end +end + + class Zookeeper def feed(args={}) food = args.fetch(:food) diff --git a/zoo_spec.rb b/zoo_spec.rb index 4943c90..e06e468 100644 --- a/zoo_spec.rb +++ b/zoo_spec.rb @@ -61,6 +61,32 @@ lion.should be_full end end +describe Human do + it "should like bacon" do + Human.new.likes?(:bacon).should eq(true) + end + + it "should like tacos" do + Human.new.likes?(:tacos).should eq(true) + end + + it "should not like bamboo" do + Human.new.likes?(:bamboo).should eq(false) + end + + it "should take 3 meals to be full" do + human = Human.new + human.eat(:bacon) + human.should_not be_full + end + it "should take 3 meals to be full" do + human = Human.new + 3.times do + human.eat(:tacos) + end + human.should be_full + end +end describe Zookeeper do it "should be able to feed bamboo to the pandas" do @@ -75,3 +101,4 @@ Zookeeper.new.feed(food: :zeebras, to: lion) end end +