Skip to content

Submitting work #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion zoo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def full?
false
end

def visit
#insert code
end

end


Expand All @@ -35,7 +39,7 @@ def acceptable_food
end

def full?
@meals > 30
@meals > 30
end

end
Expand All @@ -61,6 +65,7 @@ def ==(other)

end

class Bacon < Food; end
class Tacos < Food; end
class Wildebeests < Food; end
class Zeebras < Food; end
Expand All @@ -75,3 +80,21 @@ def feed(args={})

end

class Human
include Animal

def acceptable_food
[Bacon.new, Tacos.new]
end
end

class FoodBarge

def acceptable_food
food = foodbarge.food_for(panda)
panda.feed(food)
end
end



27 changes: 27 additions & 0 deletions zoo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class Grasshoppers < Food; end
class Salad < Food; end


describe Tacos do
it "should know all tacos are equal" do
(Tacos.new == Tacos.new).should be_true
Expand Down Expand Up @@ -80,3 +81,29 @@ class Salad < Food; end
Zookeeper.new.feed(food: :zeebras, to: lion)
end
end

describe Human do
it "should like bacon" do
Human.new.likes?(Bacon.new).should eq(true)
end

it "should like tacos" do
Human.new.likes?(Tacos.new).should eq(true)
end

it "should not like bamboo" do
Human.new.likes?(Bamboo.new).should eq(false)
end
end

describe FoodBarge do
it "should have the zookeeper get the panda food and the panda should eat it" do
panda = Panda.new
foodbarge = FoodBarge.new
Zookeeper.new.feed(food: :foodbarge, to: panda)
foodbarge.visit
panda.should be_full
end
end