Skip to content
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

Panda level #14

Open
wants to merge 1 commit 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
18 changes: 18 additions & 0 deletions zoo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ def full?
end
end

class Human
include Animal

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

end

class Food

Expand All @@ -62,6 +70,7 @@ def ==(other)
end

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

end

class Foodbarge
def food_for(animal)
if animal == :panda
return Panda.new.acceptable_food()
else
false
end
end
end
23 changes: 23 additions & 0 deletions zoo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,26 @@ class Salad < Food; end
Zookeeper.new.feed(food: :zeebras, to: lion)
end
end

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

it "should like bacon" do
Human.new.likes?(Bacon.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 bamboo for the pandas" do
# food = Foodbarge.new.food_for(:panda)
# Panda.new.likes?(food).should eq(true)
# end
end