-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdrink_spec.rb
88 lines (68 loc) · 1.81 KB
/
drink_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
83
84
85
86
87
88
require 'spec_helper'
describe KegbotApi::Drink do
let(:client) { KegbotApi::Client.new TEST_API_BASEURL }
describe "Class Methods" do
let(:all) { client.Drink.all }
describe "::all" do
describe "Is Array Like" do
it "responds_to length" do
expect(all).to respond_to :length
end
it "responds_to []" do
expect(all).to respond_to :[]
end
end
it "length == 100" do
expect(all.length).to eq 100
end
end
describe "::find(614)" do
subject { client.Drink.find 614 }
it "Succeeds" do
expect(subject).to_not be nil
end
it "id == 614" do
expect(subject.id).to eq 614
end
it "raise NotFoundError on invalid ID" do
expect { client.Drink.find 999999 }.to raise_error(KegbotApi::NotFoundError)
end
end
end
describe "Instance Methods" do
subject { client.Drink.first }
it "id == 614" do
expect(subject.id).to eq 614
end
it "volume_ml == 222.0" do
expect(subject.volume_ml).to eq 222.0
end
it "time == '2014-02-27T00:08:15+00:00'" do
expect(subject.time).to eq DateTime.iso8601('2014-02-27T00:08:15+00:00').to_time
end
it "duration == 0" do
expect(subject.duration).to eq 0
end
it "to_s containts 'KegbotApi::Drink'" do
expect(subject.to_s).to include 'KegbotApi::Drink'
end
end
describe "Associations" do
subject { client.Drink.first }
describe "keg" do
it "Not nil" do
expect(subject.keg).to_not be nil
end
it "keg.id == 3" do
expect(subject.keg.id).to eq 3
end
end
describe "session" do
it "Not nil" do
expect(subject.session).to_not be nil
end
end
end
pending "drink.images"
pending "drink.user"
end