neuron-client 0.1.0 → 0.2.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/README.md +34 -8
- data/lib/neuron-client.rb +61 -12
- data/lib/neuron-client/{connection.rb → admin_connection.rb} +7 -7
- data/lib/neuron-client/api.rb +48 -31
- data/lib/neuron-client/membase_connection.rb +18 -0
- data/lib/neuron-client/model/admin/ad.rb +22 -0
- data/lib/neuron-client/model/admin/ad_zone.rb +15 -0
- data/lib/neuron-client/model/admin/base.rb +91 -0
- data/lib/neuron-client/model/admin/blocked_referer.rb +12 -0
- data/lib/neuron-client/model/admin/blocked_user_agent.rb +12 -0
- data/lib/neuron-client/model/admin/geo_target.rb +16 -0
- data/lib/neuron-client/model/admin/report.rb +15 -0
- data/lib/neuron-client/model/admin/s3_file.rb +12 -0
- data/lib/neuron-client/model/admin/zone.rb +15 -0
- data/lib/neuron-client/model/base.rb +38 -0
- data/lib/neuron-client/model/common/ad.rb +40 -0
- data/lib/neuron-client/model/common/ad_calculations.rb +329 -0
- data/lib/neuron-client/model/common/ad_zone.rb +17 -0
- data/lib/neuron-client/model/common/base.rb +67 -0
- data/lib/neuron-client/model/common/blocked_referer.rb +16 -0
- data/lib/neuron-client/model/common/blocked_user_agent.rb +16 -0
- data/lib/neuron-client/model/common/geo_target.rb +16 -0
- data/lib/neuron-client/model/common/report.rb +21 -0
- data/lib/neuron-client/model/common/s3_file.rb +16 -0
- data/lib/neuron-client/model/common/zone.rb +22 -0
- data/lib/neuron-client/model/common/zone_calculations.rb +41 -0
- data/lib/neuron-client/model/membase/ad.rb +31 -0
- data/lib/neuron-client/model/membase/ad_zone.rb +11 -0
- data/lib/neuron-client/model/membase/blocked_referer.rb +18 -0
- data/lib/neuron-client/model/membase/blocked_user_agent.rb +18 -0
- data/lib/neuron-client/model/membase/geo_target.rb +11 -0
- data/lib/neuron-client/model/membase/report.rb +11 -0
- data/lib/neuron-client/model/membase/s3_file.rb +11 -0
- data/lib/neuron-client/model/membase/zone.rb +19 -0
- data/lib/neuron-client/model/models.rb +14 -0
- data/lib/neuron-client/version.rb +1 -1
- data/neuron-client.gemspec +18 -11
- data/spec/fixtures/vcr_cassettes/s3_file.yml +186 -4
- data/spec/lib/admin_connection_spec.rb +82 -0
- data/spec/lib/api_spec.rb +80 -0
- data/spec/lib/membase_connection_spec.rb +27 -0
- data/spec/lib/model/admin/ad_spec.rb +34 -0
- data/spec/lib/model/admin/ad_zone_spec.rb +19 -0
- data/spec/lib/model/admin/base_spec.rb +11 -0
- data/spec/lib/model/admin/blocked_referer_spec.rb +11 -0
- data/spec/lib/model/admin/blocked_user_agent_spec.rb +11 -0
- data/spec/lib/model/admin/geo_target_spec.rb +30 -0
- data/spec/lib/model/admin/report_spec.rb +21 -0
- data/spec/lib/model/admin/s3_spec.rb +11 -0
- data/spec/lib/model/admin/zone_spec.rb +21 -0
- data/spec/lib/model/base_spec.rb +89 -0
- data/spec/lib/model/common/ad_calculations_spec.rb +1148 -0
- data/spec/lib/model/common/ad_spec.rb +11 -0
- data/spec/lib/model/common/ad_zone_spec.rb +11 -0
- data/spec/lib/model/common/base_spec.rb +11 -0
- data/spec/lib/model/common/blocked_referer_spec.rb +11 -0
- data/spec/lib/model/common/blocked_user_agent_spec.rb +11 -0
- data/spec/lib/model/common/geo_target_spec.rb +11 -0
- data/spec/lib/model/common/report_spec.rb +11 -0
- data/spec/lib/model/common/s3_spec.rb +11 -0
- data/spec/lib/model/common/zone_calculations_spec.rb +54 -0
- data/spec/lib/model/common/zone_spec.rb +11 -0
- data/spec/lib/model/membase/ad_spec.rb +50 -0
- data/spec/lib/model/membase/ad_zone_spec.rb +11 -0
- data/spec/lib/model/membase/base_spec.rb +11 -0
- data/spec/lib/model/membase/blocked_referer_spec.rb +30 -0
- data/spec/lib/model/membase/blocked_user_agent_spec.rb +30 -0
- data/spec/lib/model/membase/geo_target_spec.rb +11 -0
- data/spec/lib/model/membase/report_spec.rb +11 -0
- data/spec/lib/model/membase/s3_spec.rb +11 -0
- data/spec/lib/model/membase/zone_spec.rb +28 -0
- data/spec/lib/old_spec.rb +192 -149
- data/spec/lib/s3_file_spec.rb +45 -42
- data/spec/spec_helper.rb +2 -1
- metadata +296 -57
- data/lib/neuron-client/ad.rb +0 -39
- data/lib/neuron-client/ad_zone.rb +0 -16
- data/lib/neuron-client/blocked_referer.rb +0 -12
- data/lib/neuron-client/blocked_user_agent.rb +0 -12
- data/lib/neuron-client/connected.rb +0 -138
- data/lib/neuron-client/geo_target.rb +0 -16
- data/lib/neuron-client/real_time_stats.rb +0 -0
- data/lib/neuron-client/report.rb +0 -20
- data/lib/neuron-client/s3_file.rb +0 -10
- data/lib/neuron-client/zone.rb +0 -16
@@ -37,7 +37,46 @@
|
|
37
37
|
set-cookie:
|
38
38
|
- _neuron-admin_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFRiIlNTkyMGNkZGRkZGEzMmI3ODFiMDhlZjI3ZjZjN2Y5ZTY%3D--abc9759030ac57f081014793dd0a18200acd40ce;
|
39
39
|
path=/; HttpOnly
|
40
|
-
body: !
|
40
|
+
body: !str
|
41
|
+
str: ! '{"s3_file":{"bucket":"test","created_at":"2011-07-26T21:15:03Z","filename":"filename","id":1,"purpose":"RAW_EVENT_LOG","updated_at":"2011-07-26T21:15:03Z"}}'
|
42
|
+
net_http_res: &30964600 !ruby/object:Net::HTTPCreated
|
43
|
+
http_version: '1.0'
|
44
|
+
code: '201'
|
45
|
+
message: Created
|
46
|
+
header:
|
47
|
+
location:
|
48
|
+
- http://127.0.0.1:3000/s3_files/1
|
49
|
+
content-type:
|
50
|
+
- application/json; charset=utf-8
|
51
|
+
cache-control:
|
52
|
+
- no-cache
|
53
|
+
x-ua-compatible:
|
54
|
+
- IE=Edge
|
55
|
+
x-runtime:
|
56
|
+
- '2.156203'
|
57
|
+
server:
|
58
|
+
- WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
|
59
|
+
date:
|
60
|
+
- Tue, 26 Jul 2011 21:15:03 GMT
|
61
|
+
content-length:
|
62
|
+
- '156'
|
63
|
+
set-cookie:
|
64
|
+
- _neuron-admin_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFRiIlNTkyMGNkZGRkZGEzMmI3ODFiMDhlZjI3ZjZjN2Y5ZTY%3D--abc9759030ac57f081014793dd0a18200acd40ce;
|
65
|
+
path=/; HttpOnly
|
66
|
+
body: !str
|
67
|
+
str: ! '{"s3_file":{"bucket":"test","created_at":"2011-07-26T21:15:03Z","filename":"filename","id":1,"purpose":"RAW_EVENT_LOG","updated_at":"2011-07-26T21:15:03Z"}}'
|
68
|
+
net_http_res: *30964600
|
69
|
+
args: &30979260
|
70
|
+
:method: :post
|
71
|
+
:url: http://127.0.0.1:3000/s3_files.json?api_key=secret
|
72
|
+
:payload: ! '{"s3_file":{"bucket":"test","filename":"filename","purpose":"RAW_EVENT_LOG"}}'
|
73
|
+
:headers:
|
74
|
+
:content_type: :json
|
75
|
+
:accept: :json
|
76
|
+
code: 201
|
77
|
+
read: true
|
78
|
+
args: *30979260
|
79
|
+
code: 201
|
41
80
|
http_version: '1.1'
|
42
81
|
- !ruby/struct:VCR::HTTPInteraction
|
43
82
|
request: !ruby/struct:VCR::Request
|
@@ -72,7 +111,42 @@
|
|
72
111
|
- Tue, 26 Jul 2011 21:15:03 GMT
|
73
112
|
content-length:
|
74
113
|
- '158'
|
75
|
-
body: !
|
114
|
+
body: !str
|
115
|
+
str: ! '[{"s3_file":{"bucket":"test","created_at":"2011-07-26T21:15:03Z","filename":"filename","id":1,"purpose":"RAW_EVENT_LOG","updated_at":"2011-07-26T21:15:03Z"}}]'
|
116
|
+
net_http_res: &30899300 !ruby/object:Net::HTTPOK
|
117
|
+
http_version: '1.0'
|
118
|
+
code: '200'
|
119
|
+
message: OK
|
120
|
+
header:
|
121
|
+
content-type:
|
122
|
+
- application/json; charset=utf-8
|
123
|
+
etag:
|
124
|
+
- ! '"f28f9f731f02abb52de52eeb140f3904"'
|
125
|
+
cache-control:
|
126
|
+
- max-age=0, private, must-revalidate
|
127
|
+
x-ua-compatible:
|
128
|
+
- IE=Edge
|
129
|
+
x-runtime:
|
130
|
+
- '0.058083'
|
131
|
+
server:
|
132
|
+
- WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
|
133
|
+
date:
|
134
|
+
- Tue, 26 Jul 2011 21:15:03 GMT
|
135
|
+
content-length:
|
136
|
+
- '158'
|
137
|
+
body: !str
|
138
|
+
str: ! '[{"s3_file":{"bucket":"test","created_at":"2011-07-26T21:15:03Z","filename":"filename","id":1,"purpose":"RAW_EVENT_LOG","updated_at":"2011-07-26T21:15:03Z"}}]'
|
139
|
+
net_http_res: *30899300
|
140
|
+
args: &30918140
|
141
|
+
:method: :get
|
142
|
+
:url: http://127.0.0.1:3000/s3_files.json?api_key=secret
|
143
|
+
:headers:
|
144
|
+
:content_type: :json
|
145
|
+
:accept: :json
|
146
|
+
code: 200
|
147
|
+
read: true
|
148
|
+
args: *30918140
|
149
|
+
code: 200
|
76
150
|
http_version: '1.1'
|
77
151
|
- !ruby/struct:VCR::HTTPInteraction
|
78
152
|
request: !ruby/struct:VCR::Request
|
@@ -107,7 +181,42 @@
|
|
107
181
|
- Tue, 26 Jul 2011 21:15:03 GMT
|
108
182
|
content-length:
|
109
183
|
- '156'
|
110
|
-
body: !
|
184
|
+
body: !str
|
185
|
+
str: ! '{"s3_file":{"bucket":"test","created_at":"2011-07-26T21:15:03Z","filename":"filename","id":1,"purpose":"RAW_EVENT_LOG","updated_at":"2011-07-26T21:15:03Z"}}'
|
186
|
+
net_http_res: &30863640 !ruby/object:Net::HTTPOK
|
187
|
+
http_version: '1.0'
|
188
|
+
code: '200'
|
189
|
+
message: OK
|
190
|
+
header:
|
191
|
+
content-type:
|
192
|
+
- application/json; charset=utf-8
|
193
|
+
etag:
|
194
|
+
- ! '"67aa857a0fae3ef759591bfd7c6ce984"'
|
195
|
+
cache-control:
|
196
|
+
- max-age=0, private, must-revalidate
|
197
|
+
x-ua-compatible:
|
198
|
+
- IE=Edge
|
199
|
+
x-runtime:
|
200
|
+
- '0.058488'
|
201
|
+
server:
|
202
|
+
- WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
|
203
|
+
date:
|
204
|
+
- Tue, 26 Jul 2011 21:15:03 GMT
|
205
|
+
content-length:
|
206
|
+
- '156'
|
207
|
+
body: !str
|
208
|
+
str: ! '{"s3_file":{"bucket":"test","created_at":"2011-07-26T21:15:03Z","filename":"filename","id":1,"purpose":"RAW_EVENT_LOG","updated_at":"2011-07-26T21:15:03Z"}}'
|
209
|
+
net_http_res: *30863640
|
210
|
+
args: &30882500
|
211
|
+
:method: :get
|
212
|
+
:url: http://127.0.0.1:3000/s3_files/1.json?api_key=secret
|
213
|
+
:headers:
|
214
|
+
:content_type: :json
|
215
|
+
:accept: :json
|
216
|
+
code: 200
|
217
|
+
read: true
|
218
|
+
args: *30882500
|
219
|
+
code: 200
|
111
220
|
http_version: '1.1'
|
112
221
|
- !ruby/struct:VCR::HTTPInteraction
|
113
222
|
request: !ruby/struct:VCR::Request
|
@@ -142,7 +251,42 @@
|
|
142
251
|
- Tue, 26 Jul 2011 21:15:03 GMT
|
143
252
|
content-length:
|
144
253
|
- '156'
|
145
|
-
body: !
|
254
|
+
body: !str
|
255
|
+
str: ! '{"s3_file":{"bucket":"test","created_at":"2011-07-26T21:15:03Z","filename":"filename","id":1,"purpose":"RAW_EVENT_LOG","updated_at":"2011-07-26T21:15:03Z"}}'
|
256
|
+
net_http_res: &30800000 !ruby/object:Net::HTTPOK
|
257
|
+
http_version: '1.0'
|
258
|
+
code: '200'
|
259
|
+
message: OK
|
260
|
+
header:
|
261
|
+
content-type:
|
262
|
+
- application/json; charset=utf-8
|
263
|
+
etag:
|
264
|
+
- ! '"67aa857a0fae3ef759591bfd7c6ce984"'
|
265
|
+
cache-control:
|
266
|
+
- max-age=0, private, must-revalidate
|
267
|
+
x-ua-compatible:
|
268
|
+
- IE=Edge
|
269
|
+
x-runtime:
|
270
|
+
- '0.103646'
|
271
|
+
server:
|
272
|
+
- WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
|
273
|
+
date:
|
274
|
+
- Tue, 26 Jul 2011 21:15:03 GMT
|
275
|
+
content-length:
|
276
|
+
- '156'
|
277
|
+
body: !str
|
278
|
+
str: ! '{"s3_file":{"bucket":"test","created_at":"2011-07-26T21:15:03Z","filename":"filename","id":1,"purpose":"RAW_EVENT_LOG","updated_at":"2011-07-26T21:15:03Z"}}'
|
279
|
+
net_http_res: *30800000
|
280
|
+
args: &30814500
|
281
|
+
:method: :get
|
282
|
+
:url: http://127.0.0.1:3000/s3_files/1.json?api_key=secret
|
283
|
+
:headers:
|
284
|
+
:content_type: :json
|
285
|
+
:accept: :json
|
286
|
+
code: 200
|
287
|
+
read: true
|
288
|
+
args: *30814500
|
289
|
+
code: 200
|
146
290
|
http_version: '1.1'
|
147
291
|
- !ruby/struct:VCR::HTTPInteraction
|
148
292
|
request: !ruby/struct:VCR::Request
|
@@ -219,3 +363,41 @@
|
|
219
363
|
- '158'
|
220
364
|
body: ! '{"s3_file":{"bucket":"test","created_at":"2011-07-26T21:15:03Z","filename":"filename_2","id":1,"purpose":"RAW_EVENT_LOG","updated_at":"2011-07-26T21:15:03Z"}}'
|
221
365
|
http_version: '1.1'
|
366
|
+
- !ruby/struct:VCR::HTTPInteraction
|
367
|
+
request: !ruby/struct:VCR::Request
|
368
|
+
method: :put
|
369
|
+
uri: http://127.0.0.1:3000//1.json?api_key=secret
|
370
|
+
body: !!null
|
371
|
+
headers:
|
372
|
+
accept:
|
373
|
+
- application/json
|
374
|
+
accept-encoding:
|
375
|
+
- gzip, deflate
|
376
|
+
content-type:
|
377
|
+
- application/json
|
378
|
+
content-length:
|
379
|
+
- '30'
|
380
|
+
response: !ruby/struct:VCR::Response
|
381
|
+
status: !ruby/struct:VCR::ResponseStatus
|
382
|
+
code: 404
|
383
|
+
message: Not Found
|
384
|
+
headers:
|
385
|
+
content-type:
|
386
|
+
- text/html
|
387
|
+
content-length:
|
388
|
+
- '627'
|
389
|
+
x-runtime:
|
390
|
+
- '0.299115'
|
391
|
+
connection:
|
392
|
+
- keep-alive
|
393
|
+
server:
|
394
|
+
- thin 1.2.11 codename Bat-Shit Crazy
|
395
|
+
body: ! "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n <title>Action
|
396
|
+
Controller: Exception caught</title>\n <style>\n body { background-color:
|
397
|
+
#fff; color: #333; }\n\n body, p, ol, ul, td {\n font-family: verdana,
|
398
|
+
arial, helvetica, sans-serif;\n font-size: 13px;\n line-height:
|
399
|
+
18px;\n }\n\n pre {\n background-color: #eee;\n padding: 10px;\n
|
400
|
+
\ font-size: 11px;\n }\n\n a { color: #000; }\n a:visited { color:
|
401
|
+
#666; }\n a:hover { color: #fff; background-color:#000; }\n </style>\n</head>\n<body>\n\n<h1>Routing
|
402
|
+
Error</h1>\n<p><pre>No route matches "/1.json"</pre></p>\n\n\n\n</body>\n</html>\n"
|
403
|
+
http_version: '1.1'
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module Neuron
|
2
|
+
module Client
|
3
|
+
describe AdminConnection do
|
4
|
+
describe "initialize(url, key)" do
|
5
|
+
it "should set the appropriate instance variables"
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "query_string(attrs={})" do
|
9
|
+
it "should return the expected value"
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "get(path="", attrs={})" do
|
13
|
+
context "when response.code is 200" do
|
14
|
+
context "when the format is :json" do
|
15
|
+
it "should call the expected methods and return the expected value"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
context "when response.code is not 200" do
|
19
|
+
it "it should raise an error"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "post(path="", form={}, attrs={})" do
|
24
|
+
context "when response.code is 201" do
|
25
|
+
context "when the format is :json" do
|
26
|
+
it "should call the expected methods and return the expected value"
|
27
|
+
end
|
28
|
+
context "when the format is not :json" do
|
29
|
+
it "should call the expected methods and return the expected value"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
context "when response.code is 422" do
|
33
|
+
context "when the format is :json" do
|
34
|
+
it "should throw the expected symbol and object"
|
35
|
+
end
|
36
|
+
context "when the format is not :json" do
|
37
|
+
it "should throw the expected symbol and object"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
context "when response.code is not 201 or 422" do
|
41
|
+
it "should raise an error"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "put(path="", form={}, attrs={})" do
|
46
|
+
context "when response.code is 200" do
|
47
|
+
context "when the format is :json" do
|
48
|
+
it "should call the expected methods and return the expected value"
|
49
|
+
end
|
50
|
+
context "when the format is not :json" do
|
51
|
+
it "should call the expected methods and return the expected value"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
context "when response.code is 422" do
|
55
|
+
context "when the format is :json" do
|
56
|
+
it "should throw the expected symbol and object"
|
57
|
+
end
|
58
|
+
context "when the format is not :json" do
|
59
|
+
it "should throw the expected symbol and object"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
context "when response.code is not 200 or 422" do
|
63
|
+
it "should raise an error"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "delete(path="", attrs={})" do
|
68
|
+
context "when response.code is 200" do
|
69
|
+
context "when format is :json" do
|
70
|
+
it "should call the expected methods and return the expected value"
|
71
|
+
end
|
72
|
+
context "when format is not :json" do
|
73
|
+
it "should call the expected methods and return the expected value"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
context "when response.code is not 200" do
|
77
|
+
it "should raise an error"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Neuron
|
2
|
+
module Client
|
3
|
+
describe API do
|
4
|
+
describe "configure" do
|
5
|
+
context "when connection_type is :admin" do
|
6
|
+
it "should call the expected methods" do
|
7
|
+
a = API.new
|
8
|
+
c = stub(:config)
|
9
|
+
a.should_receive(:config).exactly(4).times.and_return(c)
|
10
|
+
c.should_receive(:connection_type=).with(:admin)
|
11
|
+
a.should_receive(:inclusion).with(c, :connection_type, [:admin, :membase])
|
12
|
+
c.should_receive(:connection_type).exactly(2).times.and_return(:admin)
|
13
|
+
a.should_receive(:configure_admin_connection)
|
14
|
+
|
15
|
+
a.configure do |conf|
|
16
|
+
conf.connection_type = :admin
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
context "when connection_type is :membase" do
|
21
|
+
it "should call the expected methods" do
|
22
|
+
a = API.new
|
23
|
+
c = stub(:config)
|
24
|
+
a.should_receive(:config).exactly(4).times.and_return(c)
|
25
|
+
c.should_receive(:connection_type=).with(:membase)
|
26
|
+
a.should_receive(:inclusion).with(c, :connection_type, [:admin, :membase])
|
27
|
+
c.should_receive(:connection_type).exactly(2).times.and_return(:membase)
|
28
|
+
a.should_receive(:configure_membase_connection)
|
29
|
+
|
30
|
+
a.configure do |conf|
|
31
|
+
conf.connection_type = :membase
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "connection_type" do
|
38
|
+
it "should return the expected value"
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "config" do
|
42
|
+
it "should return the expected value"
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "required(obj, attrib)" do
|
46
|
+
context "when val is nil" do
|
47
|
+
it "should call the expected methods and raise an error"
|
48
|
+
end
|
49
|
+
context "when val is not nil and val.empty? does not exist" do
|
50
|
+
it "should call the expected methods and not raise an error"
|
51
|
+
end
|
52
|
+
context "when val is not nil and val.empty? exists and returns true" do
|
53
|
+
it "should call the expected methods and raise an error"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "inclusion(obj, attrib, valid_values)" do
|
58
|
+
context "when valid_values includes the attribute value" do
|
59
|
+
it "should not raise an error"
|
60
|
+
end
|
61
|
+
context "when valid_values does not include the attribute value" do
|
62
|
+
it "should raise an error"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "configure_admin_connection" do
|
67
|
+
context "when URI.parse raises an error" do
|
68
|
+
it "should raise a custom error"
|
69
|
+
end
|
70
|
+
context "when URI.parse does not raise an error" do
|
71
|
+
it "should call the expected methods"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "configure_membase_connection" do
|
76
|
+
it "should call the expected methods"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Neuron
|
2
|
+
module Client
|
3
|
+
describe MembaseConnection do
|
4
|
+
describe "initialize(servers)" do
|
5
|
+
it "should properly set @membase" do
|
6
|
+
c = stub(:client)
|
7
|
+
Dalli::Client.should_receive(:new).with('127.0.0.1:11211').and_return(c)
|
8
|
+
|
9
|
+
m = MembaseConnection.new('127.0.0.1:11211')
|
10
|
+
|
11
|
+
m.instance_variable_get(:@client).should == c
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "get(key)" do
|
16
|
+
it "should call the expected method and return the expected value" do
|
17
|
+
m = MembaseConnection.allocate
|
18
|
+
c = stub(:client)
|
19
|
+
m.instance_variable_set(:@client, c)
|
20
|
+
c.should_receive(:get).with('key_value')
|
21
|
+
|
22
|
+
m.get('key_value')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Neuron
|
2
|
+
module Client
|
3
|
+
module Model
|
4
|
+
module Admin
|
5
|
+
describe Ad do
|
6
|
+
describe "recent(statistic, parameters)" do
|
7
|
+
it "should call the expecte method and return the expected result" do
|
8
|
+
a = Ad.allocate
|
9
|
+
c = stub(:connection)
|
10
|
+
a.class.should_receive(:connection).and_return(c)
|
11
|
+
a.should_receive(:id).and_return(7)
|
12
|
+
p = stub(:parameters)
|
13
|
+
c.should_receive(:get).with('ads/7/recent/statistic_value', p).and_return('return_value')
|
14
|
+
|
15
|
+
a.recent('statistic_value', p).should == 'return_value'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "unlink(ad_id)" do
|
20
|
+
it "should call the expected method and return the expected result" do
|
21
|
+
a = Ad.allocate
|
22
|
+
c = stub(:connection)
|
23
|
+
a.class.should_receive(:connection).and_return(c)
|
24
|
+
a.should_receive(:id).and_return(7)
|
25
|
+
c.should_receive(:delete).with('ads/7/zones/33').and_return('return_value')
|
26
|
+
|
27
|
+
a.unlink(33).should == 'return_value'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Neuron
|
2
|
+
module Client
|
3
|
+
module Model
|
4
|
+
module Admin
|
5
|
+
describe AdZone do
|
6
|
+
describe "self.unlink(ad_id, zone_id)" do
|
7
|
+
it "should call the expected method and return the expected value" do
|
8
|
+
c = stub(:connection)
|
9
|
+
AdZone.should_receive(:connection).and_return(c)
|
10
|
+
c.should_receive(:delete).with('zones/1/ads/2').and_return('return_value')
|
11
|
+
|
12
|
+
AdZone.unlink(2, 1).should == 'return_value'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|