sucker 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sucker.rb +1 -1
- data/lib/sucker/stub.rb +1 -1
- data/spec/integration/france_spec.rb +56 -0
- data/spec/unit/sucker/stub_spec.rb +6 -0
- metadata +5 -3
data/lib/sucker.rb
CHANGED
@@ -6,7 +6,7 @@ require "sucker/request"
|
|
6
6
|
require "sucker/response"
|
7
7
|
|
8
8
|
# = Sucker
|
9
|
-
# Sucker is a thin Ruby wrapper to the Amazon Product Advertising API.
|
9
|
+
# Sucker is a paper-thin Ruby wrapper to the Amazon Product Advertising API.
|
10
10
|
module Sucker
|
11
11
|
AMAZON_API_VERSION = "2009-11-01"
|
12
12
|
|
data/lib/sucker/stub.rb
CHANGED
@@ -14,7 +14,7 @@ module Sucker
|
|
14
14
|
def stub(request)
|
15
15
|
request.instance_eval do
|
16
16
|
self.class.send :define_method, :fixture do
|
17
|
-
filename = Digest::MD5.hexdigest(
|
17
|
+
filename = Digest::MD5.hexdigest(uri.to_s)
|
18
18
|
"#{Sucker.fixtures_path}/#{filename}.xml"
|
19
19
|
end
|
20
20
|
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Sucker
|
4
|
+
describe "Item lookup" do
|
5
|
+
before do
|
6
|
+
@worker = Sucker.new(
|
7
|
+
:locale => "fr",
|
8
|
+
:key => amazon["key"],
|
9
|
+
:secret => amazon["secret"])
|
10
|
+
|
11
|
+
# @worker.curl { |curl| curl.verbose = true }
|
12
|
+
|
13
|
+
@worker << {
|
14
|
+
"Operation" => "ItemLookup",
|
15
|
+
"IdType" => "ASIN",
|
16
|
+
"Condition" => "All",
|
17
|
+
"MerchantId" => "All",
|
18
|
+
"ResponseGroup" => ["ItemAttributes", "OfferFull"] }
|
19
|
+
|
20
|
+
Sucker.stub(@worker)
|
21
|
+
end
|
22
|
+
|
23
|
+
context "single item" do
|
24
|
+
before do
|
25
|
+
@worker << { "ItemId" => "0816614024" }
|
26
|
+
@item = @worker.get.to_h["ItemLookupResponse"]["Items"]["Item"]
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns an item" do
|
30
|
+
@item.should be_an_instance_of Hash
|
31
|
+
end
|
32
|
+
|
33
|
+
it "includes an ASIN string" do
|
34
|
+
@item["ASIN"].should eql "0816614024"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "includes requested response groups" do
|
38
|
+
@item["ItemAttributes"].should be_an_instance_of Hash
|
39
|
+
@item["Offers"].should be_an_instance_of Hash
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "multiple items" do
|
44
|
+
before do
|
45
|
+
@worker << { "ItemId" => ["0816614024", "0143105825"] }
|
46
|
+
@items = @worker.get.to_h["ItemLookupResponse"]["Items"]["Item"]
|
47
|
+
pp @items
|
48
|
+
end
|
49
|
+
|
50
|
+
it "returns two items" do
|
51
|
+
@items.should be_an_instance_of Array
|
52
|
+
@items.size.should eql 2
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -45,6 +45,12 @@ module Sucker
|
|
45
45
|
it "generates a path for the fixture" do
|
46
46
|
@worker.fixture.should match /.*\/[0-9a-f]{32}\.xml$/
|
47
47
|
end
|
48
|
+
|
49
|
+
it "generates unique fixtures across venues" do
|
50
|
+
us_fixture = @worker.fixture
|
51
|
+
@worker.locale = "fr"
|
52
|
+
@worker.fixture.should_not eql us_fixture
|
53
|
+
end
|
48
54
|
end
|
49
55
|
end
|
50
56
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sucker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 2
|
10
|
+
version: 0.6.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Hakan Ensari
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- lib/sucker/stub.rb
|
88
88
|
- README.md
|
89
89
|
- spec/benchmark/to_hash_implementations.rb
|
90
|
+
- spec/integration/france_spec.rb
|
90
91
|
- spec/integration/item_lookup_spec.rb
|
91
92
|
- spec/integration/japan_spec.rb
|
92
93
|
- spec/integration/seller_listing_search_spec.rb
|
@@ -134,6 +135,7 @@ specification_version: 3
|
|
134
135
|
summary: A paper-thin Ruby wrapper to the Amazon Product Advertising API
|
135
136
|
test_files:
|
136
137
|
- spec/benchmark/to_hash_implementations.rb
|
138
|
+
- spec/integration/france_spec.rb
|
137
139
|
- spec/integration/item_lookup_spec.rb
|
138
140
|
- spec/integration/japan_spec.rb
|
139
141
|
- spec/integration/seller_listing_search_spec.rb
|