tepco_usage_api 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tepco_usage_api.rb +6 -0
- data/spec/tepco_usage_api_spec.rb +43 -0
- metadata +1 -1
data/lib/tepco_usage_api.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.expand_path(File.join(
|
2
2
|
File.dirname(__FILE__), 'spec_helper'))
|
3
|
+
require 'date'
|
3
4
|
|
4
5
|
describe TepcoUsage do
|
5
6
|
describe "#latest" do
|
@@ -30,4 +31,46 @@ describe TepcoUsage do
|
|
30
31
|
end
|
31
32
|
|
32
33
|
end
|
34
|
+
describe "#at" do
|
35
|
+
context "Given Date object" do
|
36
|
+
before do
|
37
|
+
today = Date.today
|
38
|
+
path = "/#{today.year}/#{today.month}/#{today.day}.json"
|
39
|
+
TepcoUsage.stub!(:request).with(path).and_return do
|
40
|
+
mock = mock(Object.new, :body => <<-JSON)
|
41
|
+
[
|
42
|
+
{
|
43
|
+
"saving": false,
|
44
|
+
"hour": 0,
|
45
|
+
"capacity_updated": "2011-03-25 16:05:00",
|
46
|
+
"month": 3,
|
47
|
+
"usage_updated": "2011-03-25 16:30:49",
|
48
|
+
"entryfor": "2011-03-25 15:00:00",
|
49
|
+
"capacity_peak_period": null,
|
50
|
+
"year": 2011,
|
51
|
+
"usage": 2889,
|
52
|
+
"capacity": 3750,
|
53
|
+
"day": 26
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"saving": false,
|
57
|
+
"hour": 1,
|
58
|
+
"capacity_updated": "2011-03-25 16:05:00",
|
59
|
+
"month": 3,
|
60
|
+
"usage_updated": "2011-03-25 17:05:49",
|
61
|
+
"entryfor": "2011-03-25 16:00:00",
|
62
|
+
"capacity_peak_period": null,
|
63
|
+
"year": 2011,
|
64
|
+
"usage": 2758,
|
65
|
+
"capacity": 3750,
|
66
|
+
"day": 26
|
67
|
+
}
|
68
|
+
]
|
69
|
+
JSON
|
70
|
+
end
|
71
|
+
end
|
72
|
+
subject{TepcoUsage.at(Date.today)}
|
73
|
+
it { should_not be_nil }
|
74
|
+
end
|
75
|
+
end
|
33
76
|
end
|