Skip to content

My pull request #5

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 7 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
21 changes: 18 additions & 3 deletions zoo_spec.rb → spec/zoo_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Zoo spec file
require "./zoo"
require_relative "../zoo"
require "rspec"

class Grasshoppers < Food; end
Expand Down Expand Up @@ -28,14 +28,14 @@ class Salad < Food; end
it "should be full after eating 30 bamboo" do
panda = Panda.new
31.times do
panda.eat(Bamboo.new)
panda.eat(Bamboo.new)
end
panda.should be_full
end

it "should not be full after 1" do
panda = Panda.new
panda.eat(Bamboo.new)
panda.eat(Bamboo.new)
panda.should_not be_full
end
end
Expand Down Expand Up @@ -80,3 +80,18 @@ 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).should be_true
end

it "should like tacos" do
Human.new.likes?(:tacos).should be_true
end

it "should like bamboo" do
Human.new.likes?(:bamboo).should_not be_true
end
end

13 changes: 11 additions & 2 deletions zoo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def full?
end



class Food

def ==(other)
Expand All @@ -66,12 +67,20 @@ class Wildebeests < Food; end
class Zeebras < Food; end
class Bamboo < Food; end


class Zookeeper
def feed(args={})
food = args.fetch(:food)
panda = args.fetch(:to)
panda.eat(food)
animal = args.fetch(:to)
animal.eat(food)
end

end

class Food
attr_reader :name

def initialize(name)
@name = name
end
end