sucker 0.9.2 → 1.0.0.beta.1
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.markdown +4 -20
- data/lib/sucker/request.rb +16 -9
- data/lib/sucker/response.rb +5 -4
- data/lib/sucker/version.rb +1 -1
- data/lib/sucker.rb +2 -4
- data/spec/fixtures/cassette_library/integration/errors.yml +27 -0
- data/spec/fixtures/cassette_library/integration/france.yml +27 -0
- data/spec/fixtures/cassette_library/integration/images.yml +27 -0
- data/spec/fixtures/cassette_library/integration/item_lookup/multiple.yml +27 -0
- data/spec/fixtures/cassette_library/integration/item_lookup/single.yml +27 -0
- data/spec/fixtures/cassette_library/integration/item_search.yml +27 -0
- data/spec/fixtures/cassette_library/integration/japan.yml +27 -0
- data/spec/fixtures/cassette_library/integration/related_items/child.yml +27 -0
- data/spec/fixtures/cassette_library/integration/related_items/parent.yml +27 -0
- data/spec/fixtures/cassette_library/integration/seller_listings_search.yml +27 -0
- data/spec/fixtures/cassette_library/integration/twenty_items.yml +27 -0
- data/spec/fixtures/cassette_library/unit/sucker/request.yml +32 -0
- data/spec/fixtures/cassette_library/unit/sucker/response.yml +27 -0
- data/spec/integration/errors_spec.rb +7 -8
- data/spec/integration/france_spec.rb +15 -33
- data/spec/integration/images_spec.rb +12 -12
- data/spec/integration/item_lookup_spec.rb +25 -22
- data/spec/integration/item_search_spec.rb +12 -8
- data/spec/integration/japan_spec.rb +12 -15
- data/spec/integration/related_items_spec.rb +21 -16
- data/spec/integration/seller_listing_search_spec.rb +10 -11
- data/spec/integration/twenty_items_in_one_request_spec.rb +20 -19
- data/spec/spec_helper.rb +1 -0
- data/spec/support/amazon.yml +2 -0
- data/spec/support/amazon_credentials.rb +1 -0
- data/spec/support/asins.rb +1 -0
- data/spec/support/vcr.rb +14 -0
- data/spec/unit/sucker/request_spec.rb +45 -33
- data/spec/unit/sucker/response_spec.rb +27 -24
- data/spec/unit/sucker_spec.rb +1 -0
- metadata +114 -38
- data/lib/sucker/stub.rb +0 -45
- data/spec/support/sucker.rb +0 -3
- data/spec/unit/sucker/stub_spec.rb +0 -68
@@ -1,68 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "fileutils"
|
3
|
-
|
4
|
-
module Sucker
|
5
|
-
describe "Stub" do
|
6
|
-
before do
|
7
|
-
@worker = Sucker.new(
|
8
|
-
:locale => "us",
|
9
|
-
:secret => "secret")
|
10
|
-
end
|
11
|
-
|
12
|
-
context ".stub" do
|
13
|
-
before do
|
14
|
-
Sucker.stub(@worker)
|
15
|
-
end
|
16
|
-
|
17
|
-
after do
|
18
|
-
FileUtils.rm @worker.fixture, :force => true
|
19
|
-
end
|
20
|
-
|
21
|
-
it "defines Request#fixture" do
|
22
|
-
@worker.should respond_to :fixture
|
23
|
-
@worker.fixture.should include Sucker.fixtures_path
|
24
|
-
end
|
25
|
-
|
26
|
-
it "performs the request if fixture is not available" do
|
27
|
-
curl = @worker.curl
|
28
|
-
curl.stub(:get).and_return(nil)
|
29
|
-
curl.stub!(:body_str).and_return("foo")
|
30
|
-
|
31
|
-
@worker.get
|
32
|
-
|
33
|
-
File.exists?(@worker.fixture).should be_true
|
34
|
-
File.new(@worker.fixture, "r").read.should eql "foo"
|
35
|
-
end
|
36
|
-
|
37
|
-
it "mocks the request if fixture is available" do
|
38
|
-
File.open(@worker.fixture, "w") { |f| f.write "bar" }
|
39
|
-
|
40
|
-
@worker.get.body.should eql "bar"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context "#fixture" do
|
45
|
-
it "generates a path for the fixture" do
|
46
|
-
@worker.fixture.should match /.*\/[0-9a-f]{32}\.xml$/
|
47
|
-
end
|
48
|
-
|
49
|
-
it "generates unique fixtures across venues" do
|
50
|
-
first_fixture = @worker.fixture
|
51
|
-
@worker.locale = "fr"
|
52
|
-
@worker.fixture.should_not eql first_fixture
|
53
|
-
end
|
54
|
-
|
55
|
-
it "generates the same fixture regardless of signature" do
|
56
|
-
first_fixture = @worker.fixture
|
57
|
-
@worker.stub!(:timestamp).and_return({ "Timestamp" => "foo" })
|
58
|
-
@worker.fixture.should eql first_fixture
|
59
|
-
end
|
60
|
-
|
61
|
-
it "generates the same fixture regardless of key" do
|
62
|
-
first_fixture = @worker.fixture
|
63
|
-
@worker.key = "foo"
|
64
|
-
@worker.fixture.should eql first_fixture
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|