sucker 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/lib/sucker.rb +2 -0
- data/lib/sucker/response.rb +1 -1
- data/spec/integration/france_spec.rb +1 -6
- data/spec/integration/japan_spec.rb +1 -1
- data/spec/unit/sucker/request_spec.rb +1 -1
- data/spec/unit/sucker/response_spec.rb +21 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -63,3 +63,5 @@ Notes
|
|
63
63
|
* The unit specs should run out of the box after you `bundle install`, but the integration specs require you to create [an amazon.yml file with valid credentials](http://github.com/papercavalier/sucker/blob/master/spec/support/amazon.yml.example) in `spec/support`.
|
64
64
|
|
65
65
|
* Version 0.6.0 now has Active Support's Nokogiri-based `to_hash` under the hood. After some meddling, it does what it's supposed to do and is blazing fast. Fix up your code accordingly.
|
66
|
+
|
67
|
+
* To test specs against all rubies on your system , run `./rake_rubies.sh spec:progress`.
|
data/lib/sucker.rb
CHANGED
data/lib/sucker/response.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
2
|
require "spec_helper"
|
4
3
|
|
5
4
|
module Sucker
|
@@ -24,7 +23,7 @@ module Sucker
|
|
24
23
|
|
25
24
|
context "single item" do
|
26
25
|
before do
|
27
|
-
@worker << { "ItemId" => "
|
26
|
+
@worker << { "ItemId" => "2070119874" }
|
28
27
|
@item = @worker.get.to_h["ItemLookupResponse"]["Items"]["Item"]
|
29
28
|
end
|
30
29
|
|
@@ -32,10 +31,6 @@ module Sucker
|
|
32
31
|
@item.should be_an_instance_of Hash
|
33
32
|
end
|
34
33
|
|
35
|
-
it "includes an ASIN string" do
|
36
|
-
@item["ASIN"].should eql "0816614024"
|
37
|
-
end
|
38
|
-
|
39
34
|
it "includes requested response groups" do
|
40
35
|
@item["ItemAttributes"].should be_an_instance_of Hash
|
41
36
|
@item["Offers"].should be_an_instance_of Hash
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require "spec_helper"
|
2
3
|
|
3
4
|
module Sucker
|
@@ -8,7 +9,7 @@ module Sucker
|
|
8
9
|
curl.stub!(:body_str).and_return('<?xml version="1.0" ?><books><book><creator role="author">Gilles Deleuze</author><title>A Thousand Plateaus</title></book><book><creator role="author">Gilles Deleuze</author><title>Anti-Oedipus</title></book></books>')
|
9
10
|
curl.stub!(:response_code).and_return(200)
|
10
11
|
curl.stub!(:total_time).and_return(1.0)
|
11
|
-
@response = Response.new(curl)
|
12
|
+
@response = Sucker::Response.new(curl)
|
12
13
|
end
|
13
14
|
|
14
15
|
context ".new" do
|
@@ -33,6 +34,25 @@ module Sucker
|
|
33
34
|
it "converts a content hash to string" do
|
34
35
|
@response.to_h["books"]["book"].first["title"].should be_an_instance_of String
|
35
36
|
end
|
37
|
+
|
38
|
+
it "is aliased as to_hash" do
|
39
|
+
@response.to_hash.should eql @response.to_h
|
40
|
+
end
|
41
|
+
|
42
|
+
it "renders French" do
|
43
|
+
@response.body = "<Title>L'archéologie du savoir</Title>"
|
44
|
+
@response.to_h["Title"].should eql "L'archéologie du savoir"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "renders German" do
|
48
|
+
@response.body = "<Title>Kafka: Für eine kleine Literatur</Title>"
|
49
|
+
@response.to_h["Title"].should eql "Kafka: Für eine kleine Literatur"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "renders Japanese" do
|
53
|
+
@response.body = "<Title>スティーブ・ジョブズ 驚異のプレゼン―人々を惹きつける18の法則</Title>"
|
54
|
+
@response.to_h["Title"].should eql "スティーブ・ジョブズ 驚異のプレゼン―人々を惹きつける18の法則"
|
55
|
+
end
|
36
56
|
end
|
37
57
|
end
|
38
58
|
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: 13
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 5
|
10
|
+
version: 0.6.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Hakan Ensari
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-08-
|
19
|
+
date: 2010-08-04 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|