http_stub 0.14.0.rc2 → 0.14.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/http_stub/configurer/deprecated_dsl.rb +3 -3
- data/lib/http_stub/configurer/request/stub_activator_payload_builder.rb +2 -2
- data/lib/http_stub/configurer/request/stub_payload_builder.rb +2 -2
- data/lib/http_stub/version.rb +1 -1
- data/spec/lib/http_stub/configurer/deprecated_dsl_spec.rb +19 -19
- data/spec/lib/http_stub/configurer/request/stub_activator_payload_builder_spec.rb +8 -8
- data/spec/lib/http_stub/configurer/request/stub_payload_builder_spec.rb +2 -2
- data/spec/lib/http_stub/configurer_integration_spec.rb +4 -4
- data/spec/spec_helper.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae3af84821967d62af59d061889031ec39fdd2a2
|
4
|
+
data.tar.gz: 60a07c4687d3dd2f0a5490c1059f30335ec28b87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1379954004bf0aee00104bc4efc8212e1e79ca491ee5d2efe596d0bf0de54a9365b5524368aa943ceb5fb13de545c280b633d0b0ab2629c77d01452681395b50
|
7
|
+
data.tar.gz: dc7d720c7a7aa31b1a75cf0fdab59761c5e6c6da3ceaa0cd06d3c11015acd2c8bcac38431d69b7c5543a4b52fa2f4deb1db889bdd8c6323ac687241b7ad2e5e1
|
@@ -22,7 +22,7 @@ module HttpStub
|
|
22
22
|
|
23
23
|
def stub_activator(activation_uri, stub_uri, options)
|
24
24
|
stub_server.add_activator! do |activator|
|
25
|
-
activator.
|
25
|
+
activator.on(activation_uri)
|
26
26
|
add_stub_options_to_builder(activator, stub_uri, options)
|
27
27
|
end
|
28
28
|
end
|
@@ -46,8 +46,8 @@ module HttpStub
|
|
46
46
|
private
|
47
47
|
|
48
48
|
def add_stub_options_to_builder(stub, uri, options)
|
49
|
-
stub.
|
50
|
-
stub.
|
49
|
+
stub.match_requests(uri, options.slice(:method, :headers, :parameters))
|
50
|
+
stub.respond_with(options[:response])
|
51
51
|
end
|
52
52
|
|
53
53
|
end
|
@@ -4,13 +4,13 @@ module HttpStub
|
|
4
4
|
|
5
5
|
class StubActivatorPayloadBuilder
|
6
6
|
|
7
|
-
delegate :
|
7
|
+
delegate :match_requests, :respond_with, :and_add_stub, :and_add_stubs, to: :@stub_payload_builder
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
@stub_payload_builder = HttpStub::Configurer::Request::StubPayloadBuilder.new
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def on(uri)
|
14
14
|
@activation_uri = uri
|
15
15
|
end
|
16
16
|
|
@@ -8,12 +8,12 @@ module HttpStub
|
|
8
8
|
@args = { triggers: [] }
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
11
|
+
def match_requests(uri, args={})
|
12
12
|
@uri = uri
|
13
13
|
@args.merge!(args)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def respond_with(args)
|
17
17
|
@args.merge!(response: args)
|
18
18
|
end
|
19
19
|
|
data/lib/http_stub/version.rb
CHANGED
@@ -12,20 +12,20 @@ describe HttpStub::Configurer::DeprecatedDSL do
|
|
12
12
|
let(:options) { { method: method, headers: headers, parameters: parameters, response: response } }
|
13
13
|
|
14
14
|
before(:example) do
|
15
|
-
allow(builder).to receive(:
|
16
|
-
allow(builder).to receive(:
|
15
|
+
allow(builder).to receive(:match_requests)
|
16
|
+
allow(builder).to receive(:respond_with)
|
17
17
|
end
|
18
18
|
|
19
|
-
it "causes the builder being added to match on the provided uri" do
|
20
|
-
expect(builder).to receive(:
|
19
|
+
it "causes the builder being added to match requests on the provided uri" do
|
20
|
+
expect(builder).to receive(:match_requests).with(stub_uri, anything)
|
21
21
|
|
22
22
|
subject
|
23
23
|
end
|
24
24
|
|
25
25
|
context "when a method is provided" do
|
26
26
|
|
27
|
-
it "causes the builder being added to match on the provided method" do
|
28
|
-
expect(builder).to receive(:
|
27
|
+
it "causes the builder being added to match requests on the provided method" do
|
28
|
+
expect(builder).to receive(:match_requests).with(anything, hash_including(method: method))
|
29
29
|
|
30
30
|
subject
|
31
31
|
end
|
@@ -36,8 +36,8 @@ describe HttpStub::Configurer::DeprecatedDSL do
|
|
36
36
|
|
37
37
|
let(:options) { {} }
|
38
38
|
|
39
|
-
it "causes the builder being added to not match on method" do
|
40
|
-
expect(builder).to receive(:
|
39
|
+
it "causes the builder being added to not match requests based on method" do
|
40
|
+
expect(builder).to receive(:match_requests).with(anything, hash_excluding(:method))
|
41
41
|
|
42
42
|
subject
|
43
43
|
end
|
@@ -46,8 +46,8 @@ describe HttpStub::Configurer::DeprecatedDSL do
|
|
46
46
|
|
47
47
|
context "when parameters are provided" do
|
48
48
|
|
49
|
-
it "causes the builder being added to match on the provided parameters" do
|
50
|
-
expect(builder).to receive(:
|
49
|
+
it "causes the builder being added to match requests on the provided parameters" do
|
50
|
+
expect(builder).to receive(:match_requests).with(anything, hash_including(parameters: parameters))
|
51
51
|
|
52
52
|
subject
|
53
53
|
end
|
@@ -58,8 +58,8 @@ describe HttpStub::Configurer::DeprecatedDSL do
|
|
58
58
|
|
59
59
|
let(:options) { {} }
|
60
60
|
|
61
|
-
it "causes the builder being added to not match on parameters" do
|
62
|
-
expect(builder).to receive(:
|
61
|
+
it "causes the builder being added to not match requests based on parameters" do
|
62
|
+
expect(builder).to receive(:match_requests).with(anything, hash_excluding(:parameters))
|
63
63
|
|
64
64
|
subject
|
65
65
|
end
|
@@ -68,8 +68,8 @@ describe HttpStub::Configurer::DeprecatedDSL do
|
|
68
68
|
|
69
69
|
context "when headers are provided" do
|
70
70
|
|
71
|
-
it "causes the builder being added to match on the provided headers" do
|
72
|
-
expect(builder).to receive(:
|
71
|
+
it "causes the builder being added to match requests on the provided headers" do
|
72
|
+
expect(builder).to receive(:match_requests).with(anything, hash_including(headers: headers))
|
73
73
|
|
74
74
|
subject
|
75
75
|
end
|
@@ -80,8 +80,8 @@ describe HttpStub::Configurer::DeprecatedDSL do
|
|
80
80
|
|
81
81
|
let(:options) { {} }
|
82
82
|
|
83
|
-
it "causes the builder being added to not match on headers" do
|
84
|
-
expect(builder).to receive(:
|
83
|
+
it "causes the builder being added to not match requests based on headers" do
|
84
|
+
expect(builder).to receive(:match_requests).with(anything, hash_excluding(:headers))
|
85
85
|
|
86
86
|
subject
|
87
87
|
end
|
@@ -89,7 +89,7 @@ describe HttpStub::Configurer::DeprecatedDSL do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
it "adds the provided response data to the builder" do
|
92
|
-
expect(builder).to receive(:
|
92
|
+
expect(builder).to receive(:respond_with).with(response)
|
93
93
|
|
94
94
|
subject
|
95
95
|
end
|
@@ -170,7 +170,7 @@ describe HttpStub::Configurer::DeprecatedDSL do
|
|
170
170
|
|
171
171
|
before(:example) do
|
172
172
|
allow(stub_server).to receive(:add_activator!).and_yield(builder)
|
173
|
-
allow(builder).to receive(:
|
173
|
+
allow(builder).to receive(:on)
|
174
174
|
end
|
175
175
|
|
176
176
|
it "adds an activator to the stub server" do
|
@@ -180,7 +180,7 @@ describe HttpStub::Configurer::DeprecatedDSL do
|
|
180
180
|
end
|
181
181
|
|
182
182
|
it "causes the builder being added to activate on the provided uri" do
|
183
|
-
expect(builder).to receive(:
|
183
|
+
expect(builder).to receive(:on).with(activation_uri)
|
184
184
|
|
185
185
|
subject
|
186
186
|
end
|
@@ -11,22 +11,22 @@ describe HttpStub::Configurer::Request::StubActivatorPayloadBuilder do
|
|
11
11
|
allow(HttpStub::Configurer::Request::StubPayloadBuilder).to receive(:new).and_return(stub_builder)
|
12
12
|
end
|
13
13
|
|
14
|
-
describe "#
|
14
|
+
describe "#match_requests" do
|
15
15
|
|
16
16
|
it "delegates to a stub payload builder" do
|
17
|
-
expect(stub_builder).to receive(:
|
17
|
+
expect(stub_builder).to receive(:match_requests).with(uri, request_options)
|
18
18
|
|
19
|
-
builder.
|
19
|
+
builder.match_requests(uri, request_options)
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
23
23
|
|
24
|
-
describe "#
|
24
|
+
describe "#respond_with" do
|
25
25
|
|
26
26
|
it "delegates to a stub payload builder" do
|
27
|
-
expect(stub_builder).to receive(:
|
27
|
+
expect(stub_builder).to receive(:respond_with).with(response_options)
|
28
28
|
|
29
|
-
builder.
|
29
|
+
builder.respond_with(response_options)
|
30
30
|
end
|
31
31
|
|
32
32
|
end
|
@@ -59,11 +59,11 @@ describe HttpStub::Configurer::Request::StubActivatorPayloadBuilder do
|
|
59
59
|
|
60
60
|
subject { builder.build }
|
61
61
|
|
62
|
-
context "when a path is established" do
|
62
|
+
context "when a path on which the activator is activated is established" do
|
63
63
|
|
64
64
|
let(:activation_uri) { "http://some/activation/uri" }
|
65
65
|
|
66
|
-
before(:example) { builder.
|
66
|
+
before(:example) { builder.on(activation_uri) }
|
67
67
|
|
68
68
|
it "returns a payload that includes the activation uri" do
|
69
69
|
expect(subject).to include(activation_uri: activation_uri)
|
@@ -37,8 +37,8 @@ describe HttpStub::Configurer::Request::StubPayloadBuilder do
|
|
37
37
|
before(:example) do
|
38
38
|
allow(HttpStub::Configurer::Request::ControllableValue).to receive(:format)
|
39
39
|
|
40
|
-
builder.
|
41
|
-
builder.
|
40
|
+
builder.match_requests(uri, request_options)
|
41
|
+
builder.respond_with(response_options)
|
42
42
|
end
|
43
43
|
|
44
44
|
context "when request header is provided" do
|
@@ -500,16 +500,16 @@ describe HttpStub::Configurer, "when the server is running" do
|
|
500
500
|
let(:triggers) do
|
501
501
|
(1..3).map do |trigger_number|
|
502
502
|
stub_server.build_stub do |stub|
|
503
|
-
stub.
|
504
|
-
stub.
|
503
|
+
stub.match_requests("/triggered_stub_#{trigger_number}", method: :get)
|
504
|
+
stub.respond_with(status: 200 + trigger_number, body: "Triggered stub body #{trigger_number}")
|
505
505
|
end
|
506
506
|
end
|
507
507
|
end
|
508
508
|
|
509
509
|
before(:example) do
|
510
510
|
stub_server.add_stub! do |stub|
|
511
|
-
stub.
|
512
|
-
stub.
|
511
|
+
stub.match_requests("/stub_with_triggers", method: :get)
|
512
|
+
stub.respond_with(body: "Trigger stub body")
|
513
513
|
stub.and_add_stubs(triggers)
|
514
514
|
end
|
515
515
|
end
|
data/spec/spec_helper.rb
CHANGED