http_stub 0.18.0 → 0.18.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75535217ff4857d46b0848a19809db63b7bfecbe
|
4
|
+
data.tar.gz: ce77b9eb4347fe6713abdfd6d346aad8a81ac371
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c00f25eafc1aa46f84266e399d759c301d37937c07b6cadeef9cc70b7ac3d43ff4a87ac5c53d9ed3049f755f60da51839f164bcf1f890a4126da00574f553378
|
7
|
+
data.tar.gz: 834af43f6a410d5b1e441e6fe80d0f10bfb517645534883cd5e9b8cbddc72251279052e279919bc91060c2c009a6915ae23a995302a0f1f0f9a30d36a6ead2d9
|
@@ -15,7 +15,7 @@ module HttpStub
|
|
15
15
|
@server.add_one_stub_scenario!(name) do |stub_builder|
|
16
16
|
stub_builder.merge!(@default_stub_builder)
|
17
17
|
stub_builder.respond_with(response_overrides)
|
18
|
-
stub_builder.invoke(&block)
|
18
|
+
stub_builder.invoke(&block) if block_given?
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
data/lib/http_stub/version.rb
CHANGED
@@ -90,16 +90,12 @@ describe HttpStub::Configurer::DSL::EndpointTemplate do
|
|
90
90
|
|
91
91
|
describe "#add_scenario!" do
|
92
92
|
|
93
|
-
let(:name)
|
94
|
-
let(:
|
95
|
-
let(:block_verifier) { double("BlockVerifier") }
|
96
|
-
let(:block) { lambda { block_verifier.verify } }
|
97
|
-
|
98
|
-
let(:stub_builder) { instance_double(HttpStub::Configurer::DSL::StubBuilder).as_null_object }
|
93
|
+
let(:name) { "some_scenario_name" }
|
94
|
+
let(:stub_builder) { instance_double(HttpStub::Configurer::DSL::StubBuilder).as_null_object }
|
99
95
|
|
100
96
|
before(:example) { allow(server).to receive(:add_one_stub_scenario!).and_yield(stub_builder) }
|
101
97
|
|
102
|
-
subject { endpoint_template.add_scenario!(name
|
98
|
+
subject { endpoint_template.add_scenario!(name) }
|
103
99
|
|
104
100
|
it "add a one stub scenario to the server" do
|
105
101
|
expect(server).to receive(:add_one_stub_scenario!).with(name)
|
@@ -117,6 +113,8 @@ describe HttpStub::Configurer::DSL::EndpointTemplate do
|
|
117
113
|
|
118
114
|
let(:response_overrides) { { status: 302 } }
|
119
115
|
|
116
|
+
subject { endpoint_template.add_scenario!(name, response_overrides) }
|
117
|
+
|
120
118
|
it "informs the stub builder to respond with the response overrides" do
|
121
119
|
expect(stub_builder).to receive(:respond_with).with(response_overrides)
|
122
120
|
|
@@ -127,7 +125,7 @@ describe HttpStub::Configurer::DSL::EndpointTemplate do
|
|
127
125
|
|
128
126
|
context "when response overrides are not provided" do
|
129
127
|
|
130
|
-
subject { endpoint_template.add_scenario!(name
|
128
|
+
subject { endpoint_template.add_scenario!(name) }
|
131
129
|
|
132
130
|
it "does not change the stub builder by requesting it respond with an empty hash" do
|
133
131
|
expect(stub_builder).to receive(:respond_with).with({})
|
@@ -144,18 +142,39 @@ describe HttpStub::Configurer::DSL::EndpointTemplate do
|
|
144
142
|
subject
|
145
143
|
end
|
146
144
|
|
147
|
-
|
148
|
-
|
149
|
-
|
145
|
+
context "when a block is provided" do
|
146
|
+
|
147
|
+
let(:block_verifier) { double("BlockVerifier") }
|
148
|
+
let(:block) { lambda { block_verifier.verify } }
|
149
|
+
|
150
|
+
subject { endpoint_template.add_scenario!(name, &block) }
|
151
|
+
|
152
|
+
it "requests the added stub builder invoke the provided block" do
|
153
|
+
expect(stub_builder).to receive(:invoke).and_yield
|
154
|
+
expect(block_verifier).to receive(:verify)
|
155
|
+
|
156
|
+
subject
|
157
|
+
end
|
158
|
+
|
159
|
+
it "applies the response overrides before invoking the provided block" do
|
160
|
+
expect(stub_builder).to receive(:respond_with).ordered
|
161
|
+
expect(stub_builder).to receive(:invoke).ordered
|
162
|
+
|
163
|
+
subject
|
164
|
+
end
|
150
165
|
|
151
|
-
subject
|
152
166
|
end
|
153
167
|
|
154
|
-
|
155
|
-
|
156
|
-
|
168
|
+
context "when a block is not provided" do
|
169
|
+
|
170
|
+
subject { endpoint_template.add_scenario!(name) }
|
171
|
+
|
172
|
+
it "does not requests the added stub builder invoke a block" do
|
173
|
+
expect(stub_builder).not_to receive(:invoke)
|
174
|
+
|
175
|
+
subject
|
176
|
+
end
|
157
177
|
|
158
|
-
subject
|
159
178
|
end
|
160
179
|
|
161
180
|
end
|