http_stub 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,6 +30,7 @@ module HttpStub
30
30
  request.body = {
31
31
  "uri" => uri,
32
32
  "method" => options[:method],
33
+ "parameters" => options[:parameters] || {},
33
34
  "response" => {
34
35
  "status" => response_options[:status] || "200",
35
36
  "body" => response_options[:body]
@@ -1,3 +1,3 @@
1
1
  module HttpStub
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -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
- before(:each) { client.stub_response!("/a_path", method: :get, response: { status: 200, body: "Some body" }) }
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
- describe "and that request is made" do
24
+ let(:response) { Net::HTTP.get_response("localhost", "/a_path", 8001) }
18
25
 
19
- let(:response) { Net::HTTP.get_response("localhost", "/a_path", 8001) }
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 "and the stub is cleared" do
51
+ describe "that contains parameters" do
29
52
 
30
- before(:each) { client.clear! }
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 the original request is made" do
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.2
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-20 00:00:00.000000000 Z
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: 1080300762408151484
186
+ hash: 3112454833684141326
187
187
  requirements: []
188
188
  rubyforge_project: http_stub
189
189
  rubygems_version: 1.8.25