-
Notifications
You must be signed in to change notification settings - Fork 11
/
zoo_spec.rb
82 lines (68 loc) · 1.61 KB
/
zoo_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Zoo spec file
require "./zoo"
require "rspec"
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
end
end
describe Panda do
it "should like bamboo" do
Panda.new.likes?(Bamboo.new).should eq(true)
end
it "should not like grasshoppers" do
Panda.new.likes?(Grasshoppers.new).should eq(false)
end
it "should be able to eat the food" do
Panda.new.eat(Bamboo.new).should be_true
end
it "should be full after eating 30 bamboo" do
panda = Panda.new
31.times do
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.should_not be_full
end
end
describe Lion do
it "should like wildebeests" do
Lion.new.likes?(Wildebeests.new).should eq(true)
end
it "should like zeebras" do
Lion.new.likes?(Zeebras.new).should eq(true)
end
it "should not like salad" do
Lion.new.likes?(Salad.new).should eq(false)
end
it "should take 11 meals to be full" do
lion = Lion.new
lion.eat(Zeebras.new)
lion.should_not be_full
end
it "should take 11 meals to be full" do
lion = Lion.new
11.times do
lion.eat(Zeebras.new)
end
lion.should be_full
end
end
describe Zookeeper do
it "should be able to feed bamboo to the pandas" do
panda = Panda.new
panda.should_receive(:eat).with(:bamboo)
Zookeeper.new.feed(food: :bamboo, to: panda)
end
it "should be able to feed zeebras to the lions" do
lion = Lion.new
lion.should_receive(:eat).with(:zeebras)
Zookeeper.new.feed(food: :zeebras, to: lion)
end
end