http_stub 0.1.2 → 0.1.3
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/lib/http_stub/client.rb +1 -0
- data/lib/http_stub/version.rb +1 -1
- data/spec/lib/http_stub/client_integration_spec.rb +45 -10
- metadata +3 -3
data/lib/http_stub/client.rb
CHANGED
data/lib/http_stub/version.rb
CHANGED
@@ -10,28 +10,63 @@ describe HttpStub::Client do
|
|
10
10
|
|
11
11
|
let(:client) { TestClient.new }
|
12
12
|
|
13
|
+
after(:each) { client.clear! }
|
14
|
+
|
13
15
|
describe "when a response for a request is stubbed" do
|
14
16
|
|
15
|
-
|
17
|
+
describe "that contains no parameters" do
|
18
|
+
|
19
|
+
before(:each) { client.stub_response!("/a_path", method: :get,
|
20
|
+
response: { status: 200, body: "Some body" }) }
|
21
|
+
|
22
|
+
describe "and that request is made" do
|
16
23
|
|
17
|
-
|
24
|
+
let(:response) { Net::HTTP.get_response("localhost", "/a_path", 8001) }
|
18
25
|
|
19
|
-
|
26
|
+
it "should replay the stubbed response" do
|
27
|
+
response.code.should eql("200")
|
28
|
+
response.body.should eql("Some body")
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "and the stub is cleared" do
|
34
|
+
|
35
|
+
before(:each) { client.clear! }
|
36
|
+
|
37
|
+
describe "and the original request is made" do
|
38
|
+
|
39
|
+
let(:response) { Net::HTTP.get_response("localhost", "/a_path", 8001) }
|
40
|
+
|
41
|
+
it "should respond with a 404 status code" do
|
42
|
+
response.code.should eql("404")
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
20
46
|
|
21
|
-
it "should replay the stubbed response" do
|
22
|
-
response.code.should eql("200")
|
23
|
-
response.body.should eql("Some body")
|
24
47
|
end
|
25
48
|
|
26
49
|
end
|
27
50
|
|
28
|
-
describe "
|
51
|
+
describe "that contains parameters" do
|
29
52
|
|
30
|
-
before(:each) { client.
|
53
|
+
before(:each) { client.stub_response!("/a_path", method: :get, parameters: { key: "value" },
|
54
|
+
response: { status: 200, body: "Some body" }) }
|
31
55
|
|
32
|
-
describe "and
|
56
|
+
describe "and that request is made" do
|
33
57
|
|
34
|
-
let(:response) { Net::HTTP.get_response("localhost", "/a_path", 8001) }
|
58
|
+
let(:response) { Net::HTTP.get_response("localhost", "/a_path?key=value", 8001) }
|
59
|
+
|
60
|
+
it "should replay the stubbed response" do
|
61
|
+
response.code.should eql("200")
|
62
|
+
response.body.should eql("Some body")
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "and a request with different parameters is made" do
|
68
|
+
|
69
|
+
let(:response) { Net::HTTP.get_response("localhost", "/a_path?key=another_value", 8001) }
|
35
70
|
|
36
71
|
it "should respond with a 404 status code" do
|
37
72
|
response.code.should eql("404")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_stub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-02-
|
13
|
+
date: 2013-02-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sinatra
|
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
183
|
version: '0'
|
184
184
|
segments:
|
185
185
|
- 0
|
186
|
-
hash:
|
186
|
+
hash: 3112454833684141326
|
187
187
|
requirements: []
|
188
188
|
rubyforge_project: http_stub
|
189
189
|
rubygems_version: 1.8.25
|