-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmid_term_spec.rb
75 lines (55 loc) · 2.24 KB
/
mid_term_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
require_relative '../../spec_helper.rb'
require "#{File.dirname(__FILE__)}/turkey"
describe Turkey do
before do
@turkey = Turkey.new(10)
end
it "should report the turkey weight" do
@turkey.weight.should equal 10
end
it "should be a kind of animal" do
@turkey.kind_of?(Animal).should be_true
end
it "should gobble speak" do
@turkey.gobble_speak("Hello I Am a Turkey. Please Don't Eat Me.").should eq "Gobble Gobble Gobble gobble Gobble. Gobble Gobb'le Gobble Gobble."
end
end
require "#{File.dirname(__FILE__)}/thanksgiving_dinner"
describe ThanksgivingDinner do
before do
@t_dinner = ThanksgivingDinner.new(:vegan)
@t_dinner.guests = ["Aunt Petunia", "Uncle Vernon", "Aunt Marge", "Dudley", "Harry"] # I know I just made a British family celebrate Thanksgiving, but it could be worse: It could have been the 4th of July! :)
end
it "should be a kind of dinner" do
@t_dinner.kind_of?(Dinner).should be_true
end
# Use inject here
it "should sum the letters in each guest name for the seating chart size" do
@t_dinner.seating_chart_size.should eq 45
end
it "should provide a menu" do
@t_dinner.respond_to?(:menu).should be_true
end
context "#menu" do
it "should have a diet specified" do
@t_dinner.menu[:diet].should eq :vegan
end
it "should have proteins" do
@t_dinner.menu[:proteins].should eq ["Tofurkey", "Hummus"]
end
it "should have vegetables" do
@t_dinner.menu[:veggies].should eq [:ginger_carrots , :potatoes, :yams]
end
# Dinners don't always have dessert, but ThanksgivingDinners always do!
it "should have desserts" do
@t_dinner.menu[:desserts].should eq({:pies => [:pumkin_pie], :other => ["Chocolate Moose"], :molds => [:cranberry, :mango, :cherry]})
end
end
# Use String interpolation, collection methods, and string methods for these two examples
it "should return what is on the dinner menu" do
@t_dinner.whats_for_dinner.should eq "Tonight we have proteins Tofurkey and Hummus, and veggies Ginger Carrots, Potatoes, and Yams."
end
it "should return what is on the dessert menu" do
@t_dinner.whats_for_dessert.should eq "Tonight we have 5 delicious desserts: Pumkin Pie, Chocolate Moose, and 3 molds: Cranberry and Mango and Cherry."
end
end