sucker 0.6.5 → 0.6.6
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 +9 -12
- data/lib/sucker/response.rb +1 -2
- data/lib/sucker/stub.rb +7 -1
- data/spec/unit/sucker/response_spec.rb +5 -0
- data/spec/unit/sucker/stub_spec.rb +20 -16
- metadata +4 -4
data/README.md
CHANGED
@@ -42,26 +42,23 @@ Hit Amazon again.
|
|
42
42
|
|
43
43
|
Check the integration specs for more examples.
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
Stubbing
|
46
|
+
--------
|
47
47
|
|
48
|
-
To
|
48
|
+
To stub web requests in your specs, create `spec/support/sucker_helper.rb`:
|
49
49
|
|
50
50
|
require "sucker/stub"
|
51
|
+
|
51
52
|
Sucker.fixtures_path = File.dirname(__FILE__) + "/../fixtures"
|
52
53
|
|
53
|
-
|
54
|
+
In your spec, you can now stub the worker:
|
54
55
|
|
55
56
|
@worker = Sucker.new(some_hash)
|
56
57
|
Sucker.stub(@worker)
|
57
58
|
|
58
|
-
The first time you run the spec, Sucker will perform the actual
|
59
|
-
|
60
|
-
Notes
|
61
|
-
-----
|
62
|
-
|
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`.
|
59
|
+
The first time you run the spec, Sucker will perform the actual request. Following requests will use a cached response.
|
64
60
|
|
65
|
-
|
61
|
+
Compatibility
|
62
|
+
-------------
|
66
63
|
|
67
|
-
|
64
|
+
Specs pass against Ruby 1.8.7, 1.9.1, 1.9.2, and REE.
|
data/lib/sucker/response.rb
CHANGED
data/lib/sucker/stub.rb
CHANGED
@@ -14,7 +14,13 @@ module Sucker
|
|
14
14
|
def stub(request)
|
15
15
|
request.instance_eval do
|
16
16
|
self.class.send :define_method, :fixture do
|
17
|
-
|
17
|
+
values = parameters.
|
18
|
+
reject{ |k, v| %w{AWSAccessKeyId Service}.
|
19
|
+
include? k }.
|
20
|
+
values.
|
21
|
+
flatten.
|
22
|
+
join
|
23
|
+
filename = Digest::MD5.hexdigest(host + values)
|
18
24
|
"#{Sucker.fixtures_path}/#{filename}.xml"
|
19
25
|
end
|
20
26
|
|
@@ -39,6 +39,11 @@ module Sucker
|
|
39
39
|
@response.to_hash.should eql @response.to_h
|
40
40
|
end
|
41
41
|
|
42
|
+
it "caches hash" do
|
43
|
+
hash = @response.to_h
|
44
|
+
@response.instance_variable_get(:@hash).should eql hash
|
45
|
+
end
|
46
|
+
|
42
47
|
it "renders French" do
|
43
48
|
@response.body = "<Title>L'archéologie du savoir</Title>"
|
44
49
|
@response.to_h["Title"].should eql "L'archéologie du savoir"
|
@@ -39,25 +39,29 @@ module Sucker
|
|
39
39
|
|
40
40
|
@worker.get.body.should eql "bar"
|
41
41
|
end
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
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
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
54
60
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
60
|
-
end
|
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
|
61
65
|
end
|
62
66
|
end
|
63
67
|
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: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 6
|
10
|
+
version: 0.6.6
|
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-05 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|