gauges 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +6 -0
- data/Gemfile +9 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +7 -0
- data/examples/clients.rb +9 -0
- data/examples/content.rb +19 -0
- data/examples/gauges.rb +38 -0
- data/gauges.gemspec +21 -0
- data/lib/gauges.rb +133 -0
- data/lib/gauges/version.rb +3 -0
- data/spec/fixtures/client_create +5 -0
- data/spec/fixtures/client_delete +5 -0
- data/spec/fixtures/clients +5 -0
- data/spec/fixtures/clients_http_auth_failure +5 -0
- data/spec/fixtures/content +5 -0
- data/spec/fixtures/engines +5 -0
- data/spec/fixtures/gauge +5 -0
- data/spec/fixtures/gauge_create_invalid +5 -0
- data/spec/fixtures/gauge_create_valid +7 -0
- data/spec/fixtures/gauge_delete +5 -0
- data/spec/fixtures/gauge_not_found +5 -0
- data/spec/fixtures/gauge_update +5 -0
- data/spec/fixtures/gauges +5 -0
- data/spec/fixtures/locations +5 -0
- data/spec/fixtures/me +5 -0
- data/spec/fixtures/me_update +5 -0
- data/spec/fixtures/referrers +5 -0
- data/spec/fixtures/resolutions +5 -0
- data/spec/fixtures/share_add_invalid +5 -0
- data/spec/fixtures/share_add_valid +5 -0
- data/spec/fixtures/share_remove +5 -0
- data/spec/fixtures/shares +5 -0
- data/spec/fixtures/technology +5 -0
- data/spec/fixtures/terms +5 -0
- data/spec/fixtures/traffic +5 -0
- data/spec/gauges_spec.rb +796 -0
- data/spec/helper.rb +54 -0
- metadata +144 -0
@@ -0,0 +1,5 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: application/json
|
3
|
+
Connection: keep-alive
|
4
|
+
|
5
|
+
{"shares":[{"name":"Joe ","urls":{"remove":"https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/shares/4df37acbe5947cabdd000001"},"id":"4df37acbe5947cabdd000001","type":"user","last_name":null,"email":"john@doe.com","first_name":"Joe"}]}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: application/json
|
3
|
+
Connection: keep-alive
|
4
|
+
|
5
|
+
{"browsers":[{"title":"Chrome","views":135,"versions":[{"title":"15.0","views":95},{"title":"16.0","views":22},{"title":"14.0","views":15},{"title":"17.0","views":2},{"title":"12.0","views":1}],"key":"chrome"},{"title":"Safari","views":31,"versions":[{"title":"5.1","views":22},{"title":"4.0","views":6},{"title":"5.0","views":3}],"key":"safari"},{"title":"Firefox","views":9,"versions":[{"title":"7.0","views":6},{"title":"6.0","views":1},{"title":"9.0a2","views":1},{"title":"8.0","views":1}],"key":"firefox"},{"title":"Opera","views":6,"versions":[{"title":"9.80","views":6}],"key":"opera"},{"title":"Other","views":4,"versions":[],"key":"other"},{"title":"Internet Explorer","views":4,"versions":[{"title":"8.0","views":2},{"title":"7.0","views":1},{"title":"9.0","views":1}],"key":"ie"}],"urls":{"older":"https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/technology?date=2011-10-01","newer":null},"platforms":[{"title":"Macintosh","views":142,"key":"macintosh"},{"title":"Windows","views":23,"key":"windows"},{"title":"Linux","views":9,"key":"linux"},{"title":"Android","views":7,"key":"android"},{"title":"iPhone","views":5,"key":"iphone"},{"title":"iPad","views":3,"key":"ipad"}],"date":"2011-11-02"}
|
data/spec/fixtures/terms
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: application/json
|
3
|
+
Connection: keep-alive
|
4
|
+
|
5
|
+
{"urls":{"older":"https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/terms?date=2011-10-01","previous_page":null,"next_page":null,"newer":null},"date":"2011-11-02","page":1,"per_page":50,"terms":[{"term":"","views":24},{"term":"hubot hipchat","views":9},{"term":"hipchat hubot","views":5},{"term":"hubot","views":4},{"term":"hubot http authentication","views":4},{"term":"hubot siri","views":3},{"term":"hubot+http+basic+auth","views":3},{"term":"hubot xmpp","views":2},{"term":"hubot+mustache","views":2},{"term":"hipchat+and+hubot","views":2},{"term":"pre built binaries heroku","views":2},{"term":"hubot authorized users","views":1},{"term":"ten finger typing","views":1},{"term":"hubot heroku optparse","views":1},{"term":"hubot tell","views":1},{"term":"npm+hubot","views":1},{"term":"hubot random","views":1},{"term":"hubot+script+user","views":1},{"term":"hubot test","views":1},{"term":"heroku run bash","views":1},{"term":"hubot javascript","views":1},{"term":"hipchat+hubot","views":1},{"term":"%3dhubot+set+variables","views":1},{"term":"heroku git dependencies","views":1},{"term":"hubot tell script","views":1},{"term":"how to hubot","views":1},{"term":"install hubot","views":1},{"term":"adding scripts to hubot","views":1},{"term":"globe gravity feed meat slicer","views":1},{"term":"config hubot local","views":1},{"term":"hubot in action","views":1},{"term":"hipchat hubot and me","views":1},{"term":"hubot msg.match","views":1},{"term":"hipchat and hubot","views":1},{"term":"compile apps for heroku","views":1},{"term":"hubot hipchat heroku","views":1},{"term":"hubot help","views":1},{"term":"speaker deck full screen","views":1},{"term":"hubot msg.send","views":1},{"term":"setup hubot xmpp","views":1},{"term":"bin/hubot: 3: npm: not found","views":1}]}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: application/json
|
3
|
+
Connection: keep-alive
|
4
|
+
|
5
|
+
{"urls":{"older":"https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/traffic?date=2011-10-01","newer":null},"date":"2011-11-02","traffic":[{"date":"2011-11-01","views":137,"people":72},{"date":"2011-11-02","views":53,"people":29}]}
|
data/spec/gauges_spec.rb
ADDED
@@ -0,0 +1,796 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Gauges do
|
4
|
+
context "initializing with token" do
|
5
|
+
before do
|
6
|
+
@client = Gauges.new(:token => 'asdf')
|
7
|
+
end
|
8
|
+
|
9
|
+
it "sets token" do
|
10
|
+
@client.token.should == 'asdf'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "http auth failure" do
|
15
|
+
before do
|
16
|
+
stub_get('https://secure.gaug.es/clients', :clients_http_auth_failure)
|
17
|
+
@client = Gauges.new(:token => 'asdf')
|
18
|
+
@response = @client.clients
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns status" do
|
22
|
+
@response['status'].should == 'fail'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns message" do
|
26
|
+
@response['message'].should == 'Authentication required'
|
27
|
+
end
|
28
|
+
|
29
|
+
it "has correct status code" do
|
30
|
+
@response.code.should == 401
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns correct content type" do
|
34
|
+
@response.headers['content-type'].should == 'application/json'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "making request with token" do
|
39
|
+
before do
|
40
|
+
stub_get('https://secure.gaug.es/me', :me)
|
41
|
+
@client = Gauges.new(:token => 'asdf')
|
42
|
+
end
|
43
|
+
|
44
|
+
it "sets token header for request" do
|
45
|
+
Gauges.should_receive(:get).with('/me', :headers => {
|
46
|
+
'X-Gauges-Token' => 'asdf'
|
47
|
+
}, :query => {})
|
48
|
+
@client.me
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#me" do
|
53
|
+
before do
|
54
|
+
stub_get('https://secure.gaug.es/me', :me)
|
55
|
+
@client = Gauges.new(:token => 'asdf')
|
56
|
+
@response = @client.me
|
57
|
+
end
|
58
|
+
|
59
|
+
it "returns my own information" do
|
60
|
+
@response['user']['id'].should == '4df37acbe5947cabdd000001'
|
61
|
+
@response['user']['name'].should == 'john@doe.com'
|
62
|
+
@response['user']['email'].should == 'john@doe.com'
|
63
|
+
@response['user']['first_name'].should == nil
|
64
|
+
@response['user']['last_name'].should == nil
|
65
|
+
@response['user']['urls']['self'].should == 'https://secure.gaug.es/me'
|
66
|
+
@response['user']['urls']['gauges'].should == 'https://secure.gaug.es/gauges'
|
67
|
+
@response['user']['urls']['clients'].should == 'https://secure.gaug.es/clients'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#clients" do
|
72
|
+
before do
|
73
|
+
stub_get('https://secure.gaug.es/clients', :clients)
|
74
|
+
@client = Gauges.new(:token => 'asdf')
|
75
|
+
@response = @client.clients
|
76
|
+
end
|
77
|
+
|
78
|
+
it "returns a clients hash" do
|
79
|
+
@response.should be_instance_of(Hash)
|
80
|
+
@response['clients'].size.should be(1)
|
81
|
+
|
82
|
+
client = @response['clients'].first
|
83
|
+
client['key'].should == '6c6b748646bb371a0027683cda32b7ff'
|
84
|
+
client['created_at'].should == Time.utc(2011, 11, 2, 15, 17, 53)
|
85
|
+
client['description'].should == 'HipChat'
|
86
|
+
client['urls']['self'].should == 'https://secure.gaug.es/clients/6c6b748646bb371a0027683cda32b7ff'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#create_client" do
|
91
|
+
before do
|
92
|
+
stub_post('https://secure.gaug.es/clients', :client_create)
|
93
|
+
@client = Gauges.new(:token => 'asdf')
|
94
|
+
@response = @client.create_client(:description => 'HipChat')
|
95
|
+
end
|
96
|
+
|
97
|
+
it "returns 201" do
|
98
|
+
@response.code.should == 201
|
99
|
+
end
|
100
|
+
|
101
|
+
it "returns created client" do
|
102
|
+
@response.should be_instance_of(Hash)
|
103
|
+
|
104
|
+
@response['client']['key'].should == '6c6b748646bb371a0027683cda32b7ff'
|
105
|
+
@response['client']['description'].should == 'HipChat'
|
106
|
+
@response['client']['created_at'].should == Time.utc(2011, 11, 2, 15, 17, 53)
|
107
|
+
@response['client']['urls']['self'].should == 'https://secure.gaug.es/clients/6c6b748646bb371a0027683cda32b7ff'
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#delete_client" do
|
112
|
+
before do
|
113
|
+
stub_delete('https://secure.gaug.es/clients/6c6b748646bb371a0027683cda32b7ff', :client_delete)
|
114
|
+
@client = Gauges.new(:token => 'asdf')
|
115
|
+
@response = @client.delete_client('6c6b748646bb371a0027683cda32b7ff')
|
116
|
+
end
|
117
|
+
|
118
|
+
it "returns 200" do
|
119
|
+
@response.code.should == 200
|
120
|
+
end
|
121
|
+
|
122
|
+
it "returns client" do
|
123
|
+
@response['client']['key'].should == '6c6b748646bb371a0027683cda32b7ff'
|
124
|
+
@response['client']['description'].should == 'HipChat'
|
125
|
+
@response['client']['created_at'].should == Time.utc(2011, 11, 2, 15, 17, 53)
|
126
|
+
@response['client']['urls']['self'].should == 'https://secure.gaug.es/clients/6c6b748646bb371a0027683cda32b7ff'
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "#update_me" do
|
131
|
+
context "valid" do
|
132
|
+
before do
|
133
|
+
stub_put('https://secure.gaug.es/me', :me_update)
|
134
|
+
@client = Gauges.new(:token => 'asdf')
|
135
|
+
@response = @client.update_me(:first_name => 'Frank', :last_name => 'Furter')
|
136
|
+
end
|
137
|
+
|
138
|
+
it "returns 200" do
|
139
|
+
@response.code.should == 200
|
140
|
+
end
|
141
|
+
|
142
|
+
it "returns update user" do
|
143
|
+
@response.should be_instance_of(Hash)
|
144
|
+
@response['user']['id'].should == '4df37acbe5947cabdd000001'
|
145
|
+
@response['user']['name'].should == 'john@doe.com'
|
146
|
+
@response['user']['first_name'].should == 'Joe'
|
147
|
+
@response['user']['last_name'].should == nil
|
148
|
+
@response['user']['email'].should == 'john@doe.com'
|
149
|
+
@response['user']['urls']['self'].should == 'https://secure.gaug.es/me'
|
150
|
+
@response['user']['urls']['gauges'].should == 'https://secure.gaug.es/gauges'
|
151
|
+
@response['user']['urls']['clients'].should == 'https://secure.gaug.es/clients'
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "#gauges" do
|
157
|
+
before do
|
158
|
+
stub_get('https://secure.gaug.es/gauges', :gauges)
|
159
|
+
@client = Gauges.new(:token => 'asdf')
|
160
|
+
@response = @client.gauges
|
161
|
+
end
|
162
|
+
|
163
|
+
it "returns 200" do
|
164
|
+
@response.code.should == 200
|
165
|
+
end
|
166
|
+
|
167
|
+
it "returns Hash" do
|
168
|
+
@response.should be_instance_of(Hash)
|
169
|
+
end
|
170
|
+
|
171
|
+
it "returns gauges" do
|
172
|
+
gauge = @response['gauges'][0]
|
173
|
+
|
174
|
+
gauge['title'].should == 'acme.com'
|
175
|
+
gauge['tz'].should == 'Eastern Time (US & Canada)'
|
176
|
+
gauge['id'].should == '4d597dfd6bb4ba2c48000003'
|
177
|
+
gauge['creator_id'].should == '4df37acbe5947cabdd000001'
|
178
|
+
gauge['now_in_zone'].should == Time.parse('Wed Nov 02 21:11:53 -0400 2011')
|
179
|
+
gauge['enabled'].should == true
|
180
|
+
|
181
|
+
gauge['urls']["self"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003"
|
182
|
+
gauge['urls']["shares"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/shares"
|
183
|
+
gauge['urls']["referrers"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/referrers"
|
184
|
+
gauge['urls']["technology"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/technology"
|
185
|
+
gauge['urls']["content"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/content"
|
186
|
+
gauge['urls']["locations"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/locations"
|
187
|
+
gauge['urls']["engines"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/engines"
|
188
|
+
gauge['urls']["terms"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/terms"
|
189
|
+
gauge['urls']["resolutions"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/resolutions"
|
190
|
+
gauge['urls']["traffic"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/traffic"
|
191
|
+
|
192
|
+
gauge['all_time'].should == {"views" => 8259, "people" => 5349}
|
193
|
+
gauge['today'].should == {"date" => Date.new(2011, 11, 2), "views" => 53, "people" => 29}
|
194
|
+
gauge['yesterday'].should == {"date" => Date.new(2011, 11, 1), "views" => 137, "people" => 72}
|
195
|
+
|
196
|
+
gauge['recent_hours'].should == [
|
197
|
+
{"hour"=>"21", "views"=>0, "people"=>0},
|
198
|
+
{"hour"=>"20", "views"=>0, "people"=>0},
|
199
|
+
{"hour"=>"19", "views"=>0, "people"=>0},
|
200
|
+
{"hour"=>"18", "views"=>0, "people"=>0},
|
201
|
+
{"hour"=>"17", "views"=>0, "people"=>0},
|
202
|
+
{"hour"=>"16", "views"=>0, "people"=>0},
|
203
|
+
{"hour"=>"15", "views"=>0, "people"=>0},
|
204
|
+
{"hour"=>"14", "views"=>0, "people"=>0},
|
205
|
+
{"hour"=>"13", "views"=>0, "people"=>0},
|
206
|
+
{"hour"=>"12", "views"=>0, "people"=>0},
|
207
|
+
{"hour"=>"11", "views"=>1, "people"=>1},
|
208
|
+
{"hour"=>"10", "views"=>8, "people"=>4},
|
209
|
+
{"hour"=>"09", "views"=>12, "people"=>9},
|
210
|
+
{"hour"=>"08", "views"=>9, "people"=>6},
|
211
|
+
{"hour"=>"07", "views"=>1, "people"=>0},
|
212
|
+
{"hour"=>"06", "views"=>4, "people"=>3},
|
213
|
+
{"hour"=>"05", "views"=>3, "people"=>0},
|
214
|
+
{"hour"=>"04", "views"=>0, "people"=>0},
|
215
|
+
{"hour"=>"03", "views"=>1, "people"=>1},
|
216
|
+
{"hour"=>"02", "views"=>7, "people"=>4},
|
217
|
+
{"hour"=>"01", "views"=>3, "people"=>3},
|
218
|
+
{"hour"=>"00", "views"=>4, "people"=>2},
|
219
|
+
{"hour"=>"23", "views"=>15, "people"=>6},
|
220
|
+
{"hour"=>"22", "views"=>7, "people"=>5}
|
221
|
+
]
|
222
|
+
|
223
|
+
gauge['recent_days'].should == [
|
224
|
+
{"views" => 53, "date" => Date.new(2011, 11, 02), "people" => 29},
|
225
|
+
{"views" => 137, "date" => Date.new(2011, 11, 01), "people" => 72},
|
226
|
+
{"views" => 154, "date" => Date.new(2011, 10, 31), "people" => 108},
|
227
|
+
{"views" => 70, "date" => Date.new(2011, 10, 30), "people" => 39},
|
228
|
+
{"views" => 310, "date" => Date.new(2011, 10, 29), "people" => 186},
|
229
|
+
{"views" => 360, "date" => Date.new(2011, 10, 28), "people" => 233},
|
230
|
+
{"views" => 16, "date" => Date.new(2011, 10, 27), "people" => 11},
|
231
|
+
{"views" => 17, "date" => Date.new(2011, 10, 26), "people" => 12},
|
232
|
+
{"views" => 19, "date" => Date.new(2011, 10, 25), "people" => 13},
|
233
|
+
{"views" => 10, "date" => Date.new(2011, 10, 24), "people" => 9},
|
234
|
+
{"views" => 2, "date" => Date.new(2011, 10, 23), "people" => 2},
|
235
|
+
{"views" => 6, "date" => Date.new(2011, 10, 22), "people" => 6},
|
236
|
+
{"views" => 19, "date" => Date.new(2011, 10, 21), "people" => 11},
|
237
|
+
{"views" => 65, "date" => Date.new(2011, 10, 20), "people" => 49},
|
238
|
+
{"views" => 13, "date" => Date.new(2011, 10, 19), "people" => 11},
|
239
|
+
{"views" => 8, "date" => Date.new(2011, 10, 18), "people" => 5},
|
240
|
+
{"views" => 22, "date" => Date.new(2011, 10, 17), "people" => 18},
|
241
|
+
{"views" => 24, "date" => Date.new(2011, 10, 16), "people" => 16},
|
242
|
+
{"views" => 133, "date" => Date.new(2011, 10, 15), "people" => 113},
|
243
|
+
{"views" => 366, "date" => Date.new(2011, 10, 14), "people" => 335},
|
244
|
+
{"views" => 27, "date" => Date.new(2011, 10, 13), "people" => 19},
|
245
|
+
{"views" => 19, "date" => Date.new(2011, 10, 12), "people" => 13},
|
246
|
+
{"views" => 17, "date" => Date.new(2011, 10, 11), "people" => 9},
|
247
|
+
{"views" => 80, "date" => Date.new(2011, 10, 10), "people" => 46},
|
248
|
+
{"views" => 33, "date" => Date.new(2011, 10, 9), "people" => 8},
|
249
|
+
{"views" => 20, "date" => Date.new(2011, 10, 8), "people" => 9},
|
250
|
+
{"views" => 29, "date" => Date.new(2011, 10, 7), "people" => 16},
|
251
|
+
{"views" => 143, "date" => Date.new(2011, 10, 6), "people" => 83},
|
252
|
+
{"views" => 29, "date" => Date.new(2011, 10, 5), "people" => 24},
|
253
|
+
{"views" => 89, "date" => Date.new(2011, 10, 4), "people" => 45}
|
254
|
+
]
|
255
|
+
|
256
|
+
gauge['recent_months'].should == [
|
257
|
+
{"views" => 190, "date" => Date.new(2011, 11, 1), "people" => 82},
|
258
|
+
{"views" => 2452, "date" => Date.new(2011, 10, 1), "people" => 1517},
|
259
|
+
{"views" => 868, "date" => Date.new(2011, 9, 1), "people" => 488},
|
260
|
+
{"views" => 562, "date" => Date.new(2011, 8, 1), "people" => 269},
|
261
|
+
{"views" => 3287, "date" => Date.new(2011, 7, 1), "people" => 2640},
|
262
|
+
{"views" => 224, "date" => Date.new(2011, 6, 1), "people" => 133},
|
263
|
+
{"views" => 143, "date" => Date.new(2011, 5, 1), "people" => 105},
|
264
|
+
{"views" => 86, "date" => Date.new(2011, 4, 1), "people" => 52},
|
265
|
+
{"views" => 367, "date" => Date.new(2011, 3, 1), "people" => 144},
|
266
|
+
{"views" => 80, "date" => Date.new(2011, 2, 1), "people" => 44}
|
267
|
+
]
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
describe "#create_gauge" do
|
272
|
+
context "valid" do
|
273
|
+
before do
|
274
|
+
stub_post('https://secure.gaug.es/gauges', :gauge_create_valid)
|
275
|
+
@client = Gauges.new(:token => 'asdf')
|
276
|
+
@response = @client.create_gauge({
|
277
|
+
:title => 'Example',
|
278
|
+
:tz => 'Eastern Time (US & Canada)'
|
279
|
+
})
|
280
|
+
end
|
281
|
+
|
282
|
+
it "returns 201" do
|
283
|
+
@response.code.should == 201
|
284
|
+
end
|
285
|
+
|
286
|
+
it "returns gauge" do
|
287
|
+
@response['gauge']['title'].should == 'Example'
|
288
|
+
@response['gauge']['tz'].should == 'Eastern Time (US & Canada)'
|
289
|
+
@response['gauge']['id'].should == '4eb1eaf5e5947c7408000001'
|
290
|
+
@response['gauge']['creator_id'].should == '4df37acbe5947cabdd000001'
|
291
|
+
@response['gauge']['now_in_zone'].should == Time.parse('Wed Nov 02 21:14:29 -0400 2011')
|
292
|
+
@response['gauge']['enabled'].should == true
|
293
|
+
|
294
|
+
@response['gauge']['urls']["self"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001"
|
295
|
+
@response['gauge']['urls']["shares"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/shares"
|
296
|
+
@response['gauge']['urls']["referrers"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/referrers"
|
297
|
+
@response['gauge']['urls']["technology"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/technology"
|
298
|
+
@response['gauge']['urls']["content"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/content"
|
299
|
+
@response['gauge']['urls']["locations"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/locations"
|
300
|
+
@response['gauge']['urls']["engines"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/engines"
|
301
|
+
@response['gauge']['urls']["terms"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/terms"
|
302
|
+
@response['gauge']['urls']["resolutions"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/resolutions"
|
303
|
+
@response['gauge']['urls']["traffic"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/traffic"
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
context "invalid" do
|
308
|
+
before do
|
309
|
+
stub_post('https://secure.gaug.es/gauges', :gauge_create_invalid)
|
310
|
+
@client = Gauges.new(:token => 'asdf')
|
311
|
+
@response = @client.create_gauge({
|
312
|
+
:title => 'Testing',
|
313
|
+
:tz => 'PooPoo'
|
314
|
+
})
|
315
|
+
end
|
316
|
+
|
317
|
+
it "returns 422" do
|
318
|
+
@response.code.should == 422
|
319
|
+
end
|
320
|
+
|
321
|
+
it "returns errors" do
|
322
|
+
@response['errors'].should == {'tz' => 'is not included in the list'}
|
323
|
+
end
|
324
|
+
|
325
|
+
it "returns full messages" do
|
326
|
+
@response['full_messages'].should == ['Tz is not included in the list']
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
describe "#gauge" do
|
332
|
+
context "found" do
|
333
|
+
before do
|
334
|
+
stub_get('https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003', :gauge)
|
335
|
+
@client = Gauges.new(:token => 'asdf')
|
336
|
+
@response = @client.gauge('4d597dfd6bb4ba2c48000003')
|
337
|
+
end
|
338
|
+
|
339
|
+
it "returns 200" do
|
340
|
+
@response.code.should == 200
|
341
|
+
end
|
342
|
+
|
343
|
+
it "returns gauge" do
|
344
|
+
@response['gauge']['title'].should == 'acme.com'
|
345
|
+
@response['gauge']['tz'].should == 'Eastern Time (US & Canada)'
|
346
|
+
@response['gauge']['id'].should == '4d597dfd6bb4ba2c48000003'
|
347
|
+
@response['gauge']['creator_id'].should == '4df37acbe5947cabdd000001'
|
348
|
+
@response['gauge']['now_in_zone'].should == Time.parse('Wed Nov 02 21:16:06 -0400 2011')
|
349
|
+
@response['gauge']['enabled'].should == true
|
350
|
+
|
351
|
+
@response['gauge']['urls']["self"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003"
|
352
|
+
@response['gauge']['urls']["shares"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/shares"
|
353
|
+
@response['gauge']['urls']["referrers"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/referrers"
|
354
|
+
@response['gauge']['urls']["technology"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/technology"
|
355
|
+
@response['gauge']['urls']["content"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/content"
|
356
|
+
@response['gauge']['urls']["locations"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/locations"
|
357
|
+
@response['gauge']['urls']["engines"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/engines"
|
358
|
+
@response['gauge']['urls']["terms"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/terms"
|
359
|
+
@response['gauge']['urls']["resolutions"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/resolutions"
|
360
|
+
@response['gauge']['urls']["traffic"].should == "https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/traffic"
|
361
|
+
end
|
362
|
+
end
|
363
|
+
|
364
|
+
context "not found" do
|
365
|
+
before do
|
366
|
+
stub_get('https://secure.gaug.es/gauges/1234', :gauge_not_found)
|
367
|
+
@client = Gauges.new(:token => 'asdf')
|
368
|
+
@response = @client.gauge('1234')
|
369
|
+
end
|
370
|
+
|
371
|
+
it "returns 404" do
|
372
|
+
@response.code.should == 404
|
373
|
+
end
|
374
|
+
|
375
|
+
it "returns message" do
|
376
|
+
@response['message'].should == 'Not found'
|
377
|
+
@response['status'].should == 'fail'
|
378
|
+
end
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
describe "#update_gauge" do
|
383
|
+
before do
|
384
|
+
stub_put('https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001', :gauge_update)
|
385
|
+
@client = Gauges.new(:token => 'asdf')
|
386
|
+
@response = @client.update_gauge('4eb1eaf5e5947c7408000001', :title => 'Testing')
|
387
|
+
end
|
388
|
+
|
389
|
+
it "returns 200" do
|
390
|
+
@response.code.should == 200
|
391
|
+
end
|
392
|
+
|
393
|
+
it "returns updated gauge" do
|
394
|
+
@response['gauge']['title'].should == 'New Title'
|
395
|
+
@response['gauge']['tz'].should == 'Eastern Time (US & Canada)'
|
396
|
+
@response['gauge']['id'].should == '4eb1eaf5e5947c7408000001'
|
397
|
+
@response['gauge']['creator_id'].should == '4df37acbe5947cabdd000001'
|
398
|
+
@response['gauge']['now_in_zone'].should == Time.parse('Wed Nov 02 21:18:12 -0400 2011')
|
399
|
+
@response['gauge']['enabled'].should == true
|
400
|
+
|
401
|
+
@response['gauge']['urls']["self"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001"
|
402
|
+
@response['gauge']['urls']["shares"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/shares"
|
403
|
+
@response['gauge']['urls']["referrers"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/referrers"
|
404
|
+
@response['gauge']['urls']["technology"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/technology"
|
405
|
+
@response['gauge']['urls']["content"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/content"
|
406
|
+
@response['gauge']['urls']["locations"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/locations"
|
407
|
+
@response['gauge']['urls']["engines"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/engines"
|
408
|
+
@response['gauge']['urls']["terms"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/terms"
|
409
|
+
@response['gauge']['urls']["resolutions"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/resolutions"
|
410
|
+
@response['gauge']['urls']["traffic"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/traffic"
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
describe "#delete_gauge" do
|
415
|
+
before do
|
416
|
+
stub_delete('https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001', :gauge_delete)
|
417
|
+
@client = Gauges.new(:token => 'asdf')
|
418
|
+
@response = @client.delete_gauge('4eb1eaf5e5947c7408000001')
|
419
|
+
end
|
420
|
+
|
421
|
+
it "returns 200" do
|
422
|
+
@response.code.should == 200
|
423
|
+
end
|
424
|
+
|
425
|
+
it "returns gauge" do
|
426
|
+
@response['gauge']['title'].should == 'New Title'
|
427
|
+
@response['gauge']['tz'].should == 'Eastern Time (US & Canada)'
|
428
|
+
@response['gauge']['id'].should == '4eb1eaf5e5947c7408000001'
|
429
|
+
@response['gauge']['creator_id'].should == '4df37acbe5947cabdd000001'
|
430
|
+
@response['gauge']['now_in_zone'].should == Time.parse('Wed Nov 02 21:19:08 -0400 2011')
|
431
|
+
@response['gauge']['enabled'].should == true
|
432
|
+
|
433
|
+
@response['gauge']['urls']["self"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001"
|
434
|
+
@response['gauge']['urls']["shares"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/shares"
|
435
|
+
@response['gauge']['urls']["referrers"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/referrers"
|
436
|
+
@response['gauge']['urls']["technology"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/technology"
|
437
|
+
@response['gauge']['urls']["content"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/content"
|
438
|
+
@response['gauge']['urls']["locations"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/locations"
|
439
|
+
@response['gauge']['urls']["engines"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/engines"
|
440
|
+
@response['gauge']['urls']["terms"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/terms"
|
441
|
+
@response['gauge']['urls']["resolutions"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/resolutions"
|
442
|
+
@response['gauge']['urls']["traffic"].should == "https://secure.gaug.es/gauges/4eb1eaf5e5947c7408000001/traffic"
|
443
|
+
end
|
444
|
+
end
|
445
|
+
|
446
|
+
describe "#shares" do
|
447
|
+
before do
|
448
|
+
stub_get('https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/shares', :shares)
|
449
|
+
@client = Gauges.new(:token => 'asdf')
|
450
|
+
@response = @client.shares('4d597dfd6bb4ba2c48000003')
|
451
|
+
end
|
452
|
+
|
453
|
+
it "returns 200" do
|
454
|
+
@response.code.should == 200
|
455
|
+
end
|
456
|
+
|
457
|
+
it "returns a users hash" do
|
458
|
+
@response.should be_an_instance_of(Hash)
|
459
|
+
@response['shares'].length.should == 1
|
460
|
+
share = @response['shares'].first
|
461
|
+
share['name'].should == "Joe "
|
462
|
+
share['id'].should == '4df37acbe5947cabdd000001'
|
463
|
+
share['type'].should == 'user'
|
464
|
+
share['last_name'].should == nil
|
465
|
+
share['first_name'].should == 'Joe'
|
466
|
+
share['email'].should == 'john@doe.com'
|
467
|
+
share['urls']['remove'].should == 'https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/shares/4df37acbe5947cabdd000001'
|
468
|
+
end
|
469
|
+
end
|
470
|
+
|
471
|
+
describe "#share" do
|
472
|
+
context "valid" do
|
473
|
+
before do
|
474
|
+
stub_post('https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/shares', :share_add_valid)
|
475
|
+
@client = Gauges.new(:token => 'asdf')
|
476
|
+
@response = @client.share('4d597dfd6bb4ba2c48000003', {:email => 'greg@acme.com'})
|
477
|
+
end
|
478
|
+
|
479
|
+
it "returns 200" do
|
480
|
+
@response.code.should == 200
|
481
|
+
end
|
482
|
+
|
483
|
+
it "returns hash with invites and users arrays" do
|
484
|
+
@response.should be_an_instance_of(Hash)
|
485
|
+
|
486
|
+
@response['share']['id'].should == '4eb1ed03e5947c7408000002'
|
487
|
+
@response['share']['name'].should == 'jane@doe.com'
|
488
|
+
@response['share']['type'].should == 'invite'
|
489
|
+
@response['share']['last_name'].should == nil
|
490
|
+
@response['share']['first_name'].should == nil
|
491
|
+
@response['share']['email'].should == 'jane@doe.com'
|
492
|
+
@response['share']['urls']['remove'].should == 'https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/shares/4eb1ed03e5947c7408000002'
|
493
|
+
end
|
494
|
+
end
|
495
|
+
|
496
|
+
context "invalid" do
|
497
|
+
before do
|
498
|
+
stub_post('https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/shares', :share_add_invalid)
|
499
|
+
@client = Gauges.new(:token => 'asdf')
|
500
|
+
@response = @client.share('4d597dfd6bb4ba2c48000003', {:email => 'greg@acme'})
|
501
|
+
end
|
502
|
+
|
503
|
+
it "returns 422" do
|
504
|
+
@response.code.should == 422
|
505
|
+
end
|
506
|
+
|
507
|
+
it "returns hash errors and full_messages array" do
|
508
|
+
@response.should be_an_instance_of(Hash)
|
509
|
+
|
510
|
+
@response['errors'].should have_key('email')
|
511
|
+
@response['errors']['email'].should == "does not appear to be legit"
|
512
|
+
|
513
|
+
@response['full_messages'].size.should be(1)
|
514
|
+
@response['full_messages'].first.should == "Email does not appear to be legit"
|
515
|
+
end
|
516
|
+
end
|
517
|
+
end
|
518
|
+
|
519
|
+
describe "#unshare" do
|
520
|
+
before do
|
521
|
+
stub_delete('https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/shares/4eb1ed03e5947c7408000002', :share_remove)
|
522
|
+
@client = Gauges.new(:token => 'asdf')
|
523
|
+
@response = @client.unshare('4d597dfd6bb4ba2c48000003', '4eb1ed03e5947c7408000002')
|
524
|
+
end
|
525
|
+
|
526
|
+
it "returns 200" do
|
527
|
+
@response.code.should == 200
|
528
|
+
end
|
529
|
+
|
530
|
+
it "returns hash with invites and users arrays" do
|
531
|
+
@response.should be_an_instance_of(Hash)
|
532
|
+
|
533
|
+
@response['share']['id'].should == '4eb1ed03e5947c7408000002'
|
534
|
+
@response['share']['name'].should == 'jane@doe.com'
|
535
|
+
@response['share']['type'].should == 'invite'
|
536
|
+
@response['share']['last_name'].should == nil
|
537
|
+
@response['share']['first_name'].should == nil
|
538
|
+
@response['share']['email'].should == 'jane@doe.com'
|
539
|
+
@response['share']['urls']['remove'].should == 'https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/shares/4eb1ed03e5947c7408000002'
|
540
|
+
end
|
541
|
+
end
|
542
|
+
|
543
|
+
describe "#content" do
|
544
|
+
before do
|
545
|
+
stub_get('https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/content', :content)
|
546
|
+
@client = Gauges.new(:token => 'asdf')
|
547
|
+
@response = @client.content('4d597dfd6bb4ba2c48000003')
|
548
|
+
end
|
549
|
+
|
550
|
+
it "returns 200" do
|
551
|
+
@response.code.should == 200
|
552
|
+
end
|
553
|
+
|
554
|
+
it "returns a hash with content as the primary key" do
|
555
|
+
@response.should be_an_instance_of(Hash)
|
556
|
+
@response['content'].size.should be(8)
|
557
|
+
|
558
|
+
item = @response['content'].first
|
559
|
+
item['title'].should == 'HipChat, hubot, and Me // acme.com'
|
560
|
+
item['views'].should == 31
|
561
|
+
item['path'].should == '/blog/archives/2011/10/28/hipchat-hubot-and-me/'
|
562
|
+
item['host'].should == 'acme.com'
|
563
|
+
|
564
|
+
@response['urls']['older'].should == 'https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/content?date=2011-11-01'
|
565
|
+
@response['urls']['newer'].should == nil
|
566
|
+
@response['urls']['previous_page'].should == nil
|
567
|
+
@response['urls']['next_page'].should == nil
|
568
|
+
end
|
569
|
+
end
|
570
|
+
|
571
|
+
describe "#referrers" do
|
572
|
+
before do
|
573
|
+
stub_get('https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/referrers', :referrers)
|
574
|
+
@client = Gauges.new(:token => 'asdf')
|
575
|
+
@response = @client.referrers('4d597dfd6bb4ba2c48000003')
|
576
|
+
end
|
577
|
+
|
578
|
+
it "returns 200" do
|
579
|
+
@response.code.should == 200
|
580
|
+
end
|
581
|
+
|
582
|
+
it "returns a hash with referrers as the primary key" do
|
583
|
+
@response.should be_an_instance_of(Hash)
|
584
|
+
@response['referrers'].size.should be(2)
|
585
|
+
|
586
|
+
item = @response['referrers'].first
|
587
|
+
item['url'].should == 'http://martinciu.com/2011/11/deploying-hubot-to-heroku-like-a-boss.html'
|
588
|
+
item['views'].should == 1
|
589
|
+
item['path'].should == '/2011/11/deploying-hubot-to-heroku-like-a-boss.html'
|
590
|
+
item['host'].should == 'martinciu.com'
|
591
|
+
|
592
|
+
@response['urls']['older'].should == 'https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/referrers?date=2011-11-01'
|
593
|
+
@response['urls']['newer'].should == nil
|
594
|
+
@response['urls']['previous_page'].should == nil
|
595
|
+
@response['urls']['next_page'].should == nil
|
596
|
+
|
597
|
+
end
|
598
|
+
end
|
599
|
+
|
600
|
+
describe "#traffic" do
|
601
|
+
before do
|
602
|
+
stub_get('https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/traffic', :traffic)
|
603
|
+
@client = Gauges.new(:token => 'asdf')
|
604
|
+
@response = @client.traffic('4d597dfd6bb4ba2c48000003')
|
605
|
+
end
|
606
|
+
|
607
|
+
it "returns 200" do
|
608
|
+
@response.code.should == 200
|
609
|
+
end
|
610
|
+
|
611
|
+
it "returns a hash with traffic as the primary key" do
|
612
|
+
@response.should be_an_instance_of(Hash)
|
613
|
+
@response['traffic'].size.should be(2)
|
614
|
+
|
615
|
+
item = @response['traffic'].first
|
616
|
+
item['date'].should == Date.parse('2011-11-1')
|
617
|
+
item['views'].should == 137
|
618
|
+
item['people'].should == 72
|
619
|
+
|
620
|
+
@response['urls']['older'].should == 'https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/traffic?date=2011-10-01'
|
621
|
+
@response['urls']['newer'].should == nil
|
622
|
+
@response['urls']['previous_page'].should == nil
|
623
|
+
@response['urls']['next_page'].should == nil
|
624
|
+
|
625
|
+
end
|
626
|
+
end
|
627
|
+
|
628
|
+
describe "#resolutions" do
|
629
|
+
before do
|
630
|
+
stub_get('https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/resolutions', :resolutions)
|
631
|
+
@client = Gauges.new(:token => 'asdf')
|
632
|
+
@response = @client.resolutions('4d597dfd6bb4ba2c48000003')
|
633
|
+
end
|
634
|
+
|
635
|
+
it "returns 200" do
|
636
|
+
@response.code.should == 200
|
637
|
+
end
|
638
|
+
|
639
|
+
it "returns a hash with browser_heights, browser_widths, and screen_widths" do
|
640
|
+
@response.should be_an_instance_of(Hash)
|
641
|
+
@response['browser_heights'].size.should be(5)
|
642
|
+
@response['browser_widths'].size.should be(8)
|
643
|
+
@response['screen_widths'].size.should be(8)
|
644
|
+
|
645
|
+
browser_height = @response['browser_heights'].first
|
646
|
+
browser_height['title'].should == '600'
|
647
|
+
browser_height['views'].should == 69
|
648
|
+
|
649
|
+
browser_width = @response['browser_widths'].first
|
650
|
+
browser_width['title'].should == '1280'
|
651
|
+
browser_width['views'].should == 56
|
652
|
+
|
653
|
+
screen_width = @response['screen_widths'].first
|
654
|
+
screen_width['title'].should == '1600'
|
655
|
+
screen_width['views'].should == 58
|
656
|
+
|
657
|
+
@response['urls']['older'].should == 'https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/resolutions?date=2011-10-01'
|
658
|
+
@response['urls']['newer'].should == nil
|
659
|
+
@response['urls']['previous_page'].should == nil
|
660
|
+
@response['urls']['next_page'].should == nil
|
661
|
+
end
|
662
|
+
end
|
663
|
+
|
664
|
+
describe "#technology" do
|
665
|
+
before do
|
666
|
+
stub_get('https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/technology', :technology)
|
667
|
+
@client = Gauges.new(:token => 'asdf')
|
668
|
+
@response = @client.technology('4d597dfd6bb4ba2c48000003')
|
669
|
+
end
|
670
|
+
|
671
|
+
it "returns 200" do
|
672
|
+
@response.code.should == 200
|
673
|
+
end
|
674
|
+
|
675
|
+
it "returns a hash with browsers and platforms" do
|
676
|
+
@response.should be_an_instance_of(Hash)
|
677
|
+
@response['browsers'].size.should be(6)
|
678
|
+
@response['platforms'].size.should be(6)
|
679
|
+
|
680
|
+
browser = @response['browsers'].first
|
681
|
+
browser['title'].should == 'Chrome'
|
682
|
+
browser['views'].should == 135
|
683
|
+
browser['versions'].first['title'].should == "15.0"
|
684
|
+
browser['versions'].first['views'].should == 95
|
685
|
+
|
686
|
+
platform = @response['platforms'].first
|
687
|
+
platform['title'].should == 'Macintosh'
|
688
|
+
platform['views'].should == 142
|
689
|
+
platform['key'].should == 'macintosh'
|
690
|
+
|
691
|
+
@response['urls']['older'].should == 'https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/technology?date=2011-10-01'
|
692
|
+
@response['urls']['newer'].should == nil
|
693
|
+
@response['urls']['previous_page'].should == nil
|
694
|
+
@response['urls']['next_page'].should == nil
|
695
|
+
end
|
696
|
+
end
|
697
|
+
|
698
|
+
describe "#terms" do
|
699
|
+
before do
|
700
|
+
stub_get('https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/terms', :terms)
|
701
|
+
@client = Gauges.new(:token => 'asdf')
|
702
|
+
@response = @client.terms('4d597dfd6bb4ba2c48000003')
|
703
|
+
end
|
704
|
+
|
705
|
+
it "returns 200" do
|
706
|
+
@response.code.should == 200
|
707
|
+
end
|
708
|
+
|
709
|
+
it "returns a hash with terms as the primary key" do
|
710
|
+
@response.should be_an_instance_of(Hash)
|
711
|
+
@response['terms'].size.should be(41)
|
712
|
+
|
713
|
+
item = @response['terms'][2]
|
714
|
+
item['term'].should == 'hipchat hubot'
|
715
|
+
item['views'].should == 5
|
716
|
+
|
717
|
+
@response['urls']['older'].should == 'https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/terms?date=2011-10-01'
|
718
|
+
@response['urls']['newer'].should == nil
|
719
|
+
@response['urls']['previous_page'].should == nil
|
720
|
+
@response['urls']['next_page'].should == nil
|
721
|
+
end
|
722
|
+
end
|
723
|
+
|
724
|
+
describe "#engines" do
|
725
|
+
before do
|
726
|
+
stub_get('https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/engines', :engines)
|
727
|
+
@client = Gauges.new(:token => 'asdf')
|
728
|
+
@response = @client.engines('4d597dfd6bb4ba2c48000003')
|
729
|
+
end
|
730
|
+
|
731
|
+
it "returns 200" do
|
732
|
+
@response.code.should == 200
|
733
|
+
end
|
734
|
+
|
735
|
+
it "returns a hash with engines as the primary key" do
|
736
|
+
@response.should be_an_instance_of(Hash)
|
737
|
+
@response['engines'].size.should be(1)
|
738
|
+
|
739
|
+
item = @response['engines'].first
|
740
|
+
item['title'].should == 'Google'
|
741
|
+
item['views'].should == 90
|
742
|
+
item['key'].should == 'google'
|
743
|
+
|
744
|
+
@response['urls']['older'].should == 'https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/engines?date=2011-10-01'
|
745
|
+
@response['urls']['newer'].should == nil
|
746
|
+
@response['urls']['previous_page'].should == nil
|
747
|
+
@response['urls']['next_page'].should == nil
|
748
|
+
end
|
749
|
+
end
|
750
|
+
|
751
|
+
describe "#locations" do
|
752
|
+
before do
|
753
|
+
stub_get('https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/locations', :locations)
|
754
|
+
@client = Gauges.new(:token => 'asdf')
|
755
|
+
@response = @client.locations('4d597dfd6bb4ba2c48000003')
|
756
|
+
end
|
757
|
+
|
758
|
+
it "returns 200" do
|
759
|
+
@response.code.should == 200
|
760
|
+
end
|
761
|
+
|
762
|
+
it "returns a hash with locations as the primary key" do
|
763
|
+
@response.should be_an_instance_of(Hash)
|
764
|
+
@response['locations'].size.should be(23)
|
765
|
+
|
766
|
+
item = @response['locations'].first
|
767
|
+
item['key'].should == 'US'
|
768
|
+
item['regions'].first['title'].should == 'California'
|
769
|
+
item['regions'].first['views'].should == 22
|
770
|
+
item['regions'].first['key'].should == 'CA'
|
771
|
+
|
772
|
+
@response['urls']['older'].should == 'https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/locations?date=2011-10-01'
|
773
|
+
@response['urls']['newer'].should == nil
|
774
|
+
@response['urls']['previous_page'].should == nil
|
775
|
+
@response['urls']['next_page'].should == nil
|
776
|
+
end
|
777
|
+
end
|
778
|
+
|
779
|
+
describe "#url" do
|
780
|
+
before do
|
781
|
+
url = 'https://secure.gaug.es/gauges/4d597dfd6bb4ba2c48000003/referrers?date=2011-11-01&page=2'
|
782
|
+
stub_get(url, :referrers)
|
783
|
+
@client = Gauges.new(:token => 'asdf')
|
784
|
+
@response = @client.url(url)
|
785
|
+
end
|
786
|
+
|
787
|
+
it "returns 200" do
|
788
|
+
@response.code.should == 200
|
789
|
+
end
|
790
|
+
|
791
|
+
it "returns hash" do
|
792
|
+
@response.should be_an_instance_of(Hash)
|
793
|
+
@response['referrers'].size.should be(2)
|
794
|
+
end
|
795
|
+
end
|
796
|
+
end
|