sucker 1.0.0.beta.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/CHANGELOG.md +12 -2
  2. data/README.md +5 -2
  3. data/lib/sucker.rbc +341 -0
  4. data/lib/sucker/request.rb +1 -1
  5. data/lib/sucker/request.rbc +2481 -0
  6. data/lib/sucker/response.rb +19 -7
  7. data/lib/sucker/response.rbc +1554 -0
  8. data/lib/sucker/version.rb +2 -2
  9. data/lib/sucker/version.rbc +130 -0
  10. data/spec/fixtures/asins.txt +9406 -406
  11. data/spec/fixtures/cassette_library/integration/alternate_versions.yml +27 -0
  12. data/spec/fixtures/cassette_library/integration/errors.yml +27 -0
  13. data/spec/fixtures/cassette_library/integration/france.yml +27 -0
  14. data/spec/fixtures/cassette_library/integration/images.yml +27 -0
  15. data/spec/fixtures/cassette_library/integration/item_lookup/multiple.yml +27 -0
  16. data/spec/fixtures/cassette_library/integration/item_lookup/single.yml +27 -0
  17. data/spec/fixtures/cassette_library/integration/item_search.yml +27 -0
  18. data/spec/fixtures/cassette_library/integration/japan.yml +27 -0
  19. data/spec/fixtures/cassette_library/integration/keyword_search.yml +27 -0
  20. data/spec/fixtures/cassette_library/integration/kindle.yml +27 -0
  21. data/spec/fixtures/cassette_library/integration/kindle_2.yml +27 -0
  22. data/spec/fixtures/cassette_library/integration/multiple_locales.yml +157 -0
  23. data/spec/fixtures/cassette_library/integration/power_search.yml +27 -0
  24. data/spec/fixtures/cassette_library/integration/related_items/child.yml +27 -0
  25. data/spec/fixtures/cassette_library/integration/related_items/parent.yml +27 -0
  26. data/spec/fixtures/cassette_library/integration/seller_listings_search.yml +27 -0
  27. data/spec/fixtures/cassette_library/integration/twenty_items.yml +27 -0
  28. data/spec/fixtures/cassette_library/unit/sucker/request.yml +29 -0
  29. data/spec/fixtures/cassette_library/unit/sucker/response.yml +27 -0
  30. data/spec/integration/alternate_versions_spec.rb +28 -20
  31. data/spec/integration/alternate_versions_spec.rbc +843 -0
  32. data/spec/integration/errors_spec.rb +10 -6
  33. data/spec/integration/errors_spec.rbc +964 -0
  34. data/spec/integration/france_spec.rb +33 -25
  35. data/spec/integration/france_spec.rbc +1012 -0
  36. data/spec/integration/images_spec.rb +32 -24
  37. data/spec/integration/images_spec.rbc +1047 -0
  38. data/spec/integration/item_lookup_spec.rb +11 -3
  39. data/spec/integration/item_lookup_spec.rbc +1723 -0
  40. data/spec/integration/item_search_spec.rb +6 -2
  41. data/spec/integration/item_search_spec.rbc +926 -0
  42. data/spec/integration/japan_spec.rb +27 -19
  43. data/spec/integration/japan_spec.rbc +849 -0
  44. data/spec/integration/keyword_search_spec.rb +5 -0
  45. data/spec/integration/keyword_search_spec.rbc +838 -0
  46. data/spec/integration/kindle_spec.rb +13 -5
  47. data/spec/integration/kindle_spec.rbc +1425 -0
  48. data/spec/integration/multiple_locales_spec.rb +34 -26
  49. data/spec/integration/multiple_locales_spec.rbc +1090 -0
  50. data/spec/integration/power_search_spec.rb +5 -0
  51. data/spec/integration/power_search_spec.rbc +838 -0
  52. data/spec/integration/related_items_spec.rb +41 -29
  53. data/spec/integration/related_items_spec.rbc +1228 -0
  54. data/spec/integration/seller_listing_search_spec.rb +3 -0
  55. data/spec/integration/seller_listing_search_spec.rbc +852 -0
  56. data/spec/integration/twenty_items_spec.rb +41 -34
  57. data/spec/integration/twenty_items_spec.rbc +1166 -0
  58. data/spec/spec_helper.rbc +231 -0
  59. data/spec/support/amazon.yml +3 -0
  60. data/spec/support/amazon.yml.example +1 -0
  61. data/spec/support/amazon_credentials.rbc +154 -0
  62. data/spec/support/asins.rb +6 -1
  63. data/spec/support/asins.rbc +335 -0
  64. data/spec/support/vcr.rbc +360 -0
  65. data/spec/unit/sucker/request_spec.rb +57 -23
  66. data/spec/unit/sucker/request_spec.rbc +4031 -0
  67. data/spec/unit/sucker/response_spec.rb +100 -26
  68. data/spec/unit/sucker/response_spec.rbc +3787 -0
  69. data/spec/unit/sucker_spec.rb +5 -1
  70. data/spec/unit/sucker_spec.rbc +299 -0
  71. metadata +94 -12
@@ -0,0 +1,360 @@
1
+ !RBIX
2
+ 0
3
+ x
4
+ M
5
+ 1
6
+ n
7
+ n
8
+ x
9
+ 10
10
+ __script__
11
+ i
12
+ 29
13
+ 5
14
+ 7
15
+ 0
16
+ 64
17
+ 47
18
+ 49
19
+ 1
20
+ 1
21
+ 15
22
+ 45
23
+ 2
24
+ 3
25
+ 56
26
+ 4
27
+ 50
28
+ 5
29
+ 0
30
+ 15
31
+ 45
32
+ 6
33
+ 7
34
+ 56
35
+ 8
36
+ 50
37
+ 9
38
+ 0
39
+ 15
40
+ 2
41
+ 11
42
+ I
43
+ 2
44
+ I
45
+ 0
46
+ I
47
+ 0
48
+ I
49
+ 0
50
+ n
51
+ p
52
+ 10
53
+ s
54
+ 3
55
+ vcr
56
+ x
57
+ 7
58
+ require
59
+ x
60
+ 3
61
+ VCR
62
+ n
63
+ M
64
+ 1
65
+ p
66
+ 2
67
+ x
68
+ 9
69
+ for_block
70
+ t
71
+ n
72
+ x
73
+ 9
74
+ __block__
75
+ i
76
+ 78
77
+ 57
78
+ 19
79
+ 0
80
+ 15
81
+ 20
82
+ 0
83
+ 45
84
+ 0
85
+ 1
86
+ 65
87
+ 49
88
+ 2
89
+ 0
90
+ 49
91
+ 3
92
+ 1
93
+ 7
94
+ 4
95
+ 64
96
+ 81
97
+ 5
98
+ 13
99
+ 18
100
+ 2
101
+ 49
102
+ 6
103
+ 1
104
+ 15
105
+ 15
106
+ 20
107
+ 0
108
+ 7
109
+ 7
110
+ 13
111
+ 18
112
+ 2
113
+ 49
114
+ 8
115
+ 1
116
+ 15
117
+ 15
118
+ 20
119
+ 0
120
+ 44
121
+ 43
122
+ 9
123
+ 80
124
+ 49
125
+ 10
126
+ 1
127
+ 13
128
+ 7
129
+ 11
130
+ 7
131
+ 12
132
+ 49
133
+ 13
134
+ 2
135
+ 15
136
+ 13
137
+ 7
138
+ 14
139
+ 7
140
+ 15
141
+ 35
142
+ 1
143
+ 49
144
+ 13
145
+ 2
146
+ 15
147
+ 13
148
+ 18
149
+ 2
150
+ 49
151
+ 16
152
+ 1
153
+ 15
154
+ 11
155
+ I
156
+ 7
157
+ I
158
+ 1
159
+ I
160
+ 1
161
+ I
162
+ 1
163
+ n
164
+ p
165
+ 17
166
+ x
167
+ 4
168
+ File
169
+ n
170
+ x
171
+ 11
172
+ active_path
173
+ x
174
+ 7
175
+ dirname
176
+ s
177
+ 29
178
+ /../fixtures/cassette_library
179
+ x
180
+ 1
181
+ +
182
+ x
183
+ 21
184
+ cassette_library_dir=
185
+ x
186
+ 7
187
+ webmock
188
+ x
189
+ 22
190
+ http_stubbing_library=
191
+ x
192
+ 4
193
+ Hash
194
+ x
195
+ 16
196
+ new_from_literal
197
+ x
198
+ 6
199
+ record
200
+ x
201
+ 12
202
+ new_episodes
203
+ x
204
+ 3
205
+ []=
206
+ x
207
+ 17
208
+ match_requests_on
209
+ x
210
+ 4
211
+ host
212
+ x
213
+ 25
214
+ default_cassette_options=
215
+ p
216
+ 15
217
+ I
218
+ 0
219
+ I
220
+ 3
221
+ I
222
+ 4
223
+ I
224
+ 4
225
+ I
226
+ 1d
227
+ I
228
+ 5
229
+ I
230
+ 29
231
+ I
232
+ 6
233
+ I
234
+ 2b
235
+ I
236
+ 8
237
+ I
238
+ 33
239
+ I
240
+ 7
241
+ I
242
+ 3c
243
+ I
244
+ 8
245
+ I
246
+ 4e
247
+ x
248
+ 42
249
+ /Users/snl/code/sucker/spec/support/vcr.rb
250
+ p
251
+ 1
252
+ x
253
+ 1
254
+ c
255
+ x
256
+ 6
257
+ config
258
+ x
259
+ 5
260
+ RSpec
261
+ n
262
+ M
263
+ 1
264
+ p
265
+ 2
266
+ x
267
+ 9
268
+ for_block
269
+ t
270
+ n
271
+ x
272
+ 9
273
+ __block__
274
+ i
275
+ 17
276
+ 57
277
+ 19
278
+ 0
279
+ 15
280
+ 20
281
+ 0
282
+ 45
283
+ 0
284
+ 1
285
+ 43
286
+ 2
287
+ 43
288
+ 3
289
+ 49
290
+ 4
291
+ 1
292
+ 11
293
+ I
294
+ 4
295
+ I
296
+ 1
297
+ I
298
+ 1
299
+ I
300
+ 1
301
+ n
302
+ p
303
+ 5
304
+ x
305
+ 3
306
+ VCR
307
+ n
308
+ x
309
+ 5
310
+ RSpec
311
+ x
312
+ 6
313
+ Macros
314
+ x
315
+ 6
316
+ extend
317
+ p
318
+ 5
319
+ I
320
+ 0
321
+ I
322
+ b
323
+ I
324
+ 4
325
+ I
326
+ c
327
+ I
328
+ 11
329
+ x
330
+ 42
331
+ /Users/snl/code/sucker/spec/support/vcr.rb
332
+ p
333
+ 1
334
+ x
335
+ 6
336
+ config
337
+ x
338
+ 9
339
+ configure
340
+ p
341
+ 7
342
+ I
343
+ 0
344
+ I
345
+ 1
346
+ I
347
+ 9
348
+ I
349
+ 3
350
+ I
351
+ 12
352
+ I
353
+ b
354
+ I
355
+ 1d
356
+ x
357
+ 42
358
+ /Users/snl/code/sucker/spec/support/vcr.rb
359
+ p
360
+ 0
@@ -1,7 +1,9 @@
1
1
  require "spec_helper"
2
2
 
3
3
  module Sucker
4
+
4
5
  describe Request do
6
+
5
7
  use_vcr_cassette "unit/sucker/request", :record => :new_episodes
6
8
 
7
9
  let(:worker) do
@@ -11,59 +13,66 @@ module Sucker
11
13
  :secret => "secret")
12
14
  end
13
15
 
14
- context ".new" do
16
+ describe ".new" do
17
+
15
18
  it "sets default parameters" do
16
19
  default_parameters = {
17
20
  "Service" => "AWSECommerceService",
18
21
  "Version" => Sucker::CURRENT_AMAZON_API_VERSION }
19
22
  worker.parameters.should include default_parameters
20
23
  end
24
+
21
25
  end
22
26
 
23
- context "#<<" do
27
+ describe "#<<" do
28
+
24
29
  it "merges a hash into the parameters" do
25
30
  worker << { "foo" => "bar" }
26
31
  worker.parameters["foo"].should eql "bar"
27
32
  end
33
+
28
34
  end
29
35
 
30
- context "#version=" do
36
+ describe "#version=" do
37
+
31
38
  it "sets the Amazon API version" do
32
39
  worker.version = "foo"
33
40
  worker.parameters["Version"].should eql "foo"
34
41
  end
42
+
35
43
  end
36
44
 
37
- context "#associate_tag=" do
45
+ describe "#associate_tag=" do
46
+
38
47
  it "sets the associate tag in the parameters" do
39
48
  worker.associate_tag = "foo"
40
49
  worker.parameters["AssociateTag"].should eql "foo"
41
50
  end
51
+
42
52
  end
43
53
 
44
- context "#curl" do
45
- it "returns a cURL object" do
54
+ describe "#curl" do
55
+
56
+ it "returns curl" do
46
57
  worker.curl.should be_an_instance_of Curl::Easy
47
58
  end
48
59
 
49
- it "configures the cURL object" do
50
- worker.curl.interface.should be_nil
60
+ context "when given a block" do
51
61
 
52
- worker.curl do |curl|
53
- curl.interface = "eth1"
62
+ it "yields curl" do
63
+ worker.curl.interface.should be_nil
64
+
65
+ worker.curl { |curl| curl.interface = "eth1" }
66
+
67
+ worker.curl.interface.should eql "eth1"
54
68
  end
55
69
 
56
- worker.curl.interface.should eql "eth1"
57
70
  end
58
- end
59
71
 
60
- context "#get" do
61
- it "returns a response" do
62
- worker.get.class.ancestors.should include Response
63
- end
64
72
  end
65
73
 
66
- context "#get!" do
74
+ describe "#get!" do
75
+
67
76
  it "raises if response is not valid" do
68
77
  worker << {
69
78
  "Operation" => "ItemLookup",
@@ -71,17 +80,30 @@ module Sucker
71
80
  "ItemId" => "0816614024" }
72
81
  lambda { worker.get! }.should raise_error ResponseError
73
82
  end
83
+
84
+ end
85
+
86
+ describe "#get" do
87
+
88
+ it "returns a response" do
89
+ worker.get.class.ancestors.should include Response
90
+ end
91
+
74
92
  end
75
93
 
76
- context "#key=" do
94
+ describe "#key=" do
95
+
77
96
  it "sets the Amazon AWS access key in the parameters" do
78
97
  worker.key = "foo"
79
98
  worker.parameters["AWSAccessKeyId"].should eql "foo"
80
99
  end
100
+
81
101
  end
82
102
 
83
103
  context "private methods" do
84
- context "#build_query" do
104
+
105
+ describe "#build_query" do
106
+
85
107
  it "canonicalizes parameters" do
86
108
  query = worker.send(:build_query)
87
109
  query.should match /Service=([^&]+)&Timestamp=([^&]+)&Version=([^&]+)/
@@ -110,33 +132,45 @@ module Sucker
110
132
  query = worker.send(:build_query)
111
133
  query.should match /Foo=1/
112
134
  end
135
+
113
136
  end
114
137
 
115
- context "#host" do
138
+ describe "#host" do
139
+
116
140
  it "returns a host" do
117
141
  worker.locale = "fr"
118
142
  worker.send(:host).should eql "ecs.amazonaws.fr"
119
143
  end
144
+
120
145
  end
121
146
 
122
- context "#build_signed_query" do
147
+ describe "#build_signed_query" do
148
+
123
149
  it "returns a signed query string" do
124
150
  query = worker.send :build_signed_query
125
151
  query.should match /&Signature=.*/
126
152
  end
153
+
127
154
  end
128
155
 
129
- context "#timestamp" do
156
+ describe "#timestamp" do
157
+
130
158
  it "returns a timestamp" do
131
159
  worker.send(:timestamp)["Timestamp"].should match /^\d+-\d+-\d+T\d+:\d+:\d+Z$/
132
160
  end
161
+
133
162
  end
134
163
 
135
- context "#uri" do
164
+ describe "#uri" do
165
+
136
166
  it "returns the URI with which to query Amazon" do
137
167
  worker.send(:uri).should be_an_instance_of URI::HTTP
138
168
  end
169
+
139
170
  end
171
+
140
172
  end
173
+
141
174
  end
175
+
142
176
  end