http_stub 0.19.0 → 0.19.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db776c7504fe1de45fec47a235aabd80355a1f10
|
4
|
+
data.tar.gz: 9900db1809f2a8404f17bd8c53b1d161d87c00ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7e98fe17e5a5af10bf737bc77d6766f53f4c3557a8a3130cf851fffe63089632433844a24471ec4c3e60b2976faa03fe963982a6cb5e6f5f623d047b6cf4087
|
7
|
+
data.tar.gz: f0a8e46fa7721be673816eb64e8311b92c1a6b02dd67455769cf2e676d02b7b8c38b94ff7476a4034658777942d8987b26eb91d5ff0a96692366a4e4164dc470
|
@@ -40,9 +40,9 @@ module HttpStub
|
|
40
40
|
@server_facade.define_scenario(builder.build)
|
41
41
|
end
|
42
42
|
|
43
|
-
def add_scenario_with_one_stub!(name, &block)
|
43
|
+
def add_scenario_with_one_stub!(name, builder=nil, &block)
|
44
44
|
add_scenario!(name) do |scenario|
|
45
|
-
scenario.add_stub! { |stub| stub.invoke(&block) }
|
45
|
+
scenario.add_stub!(builder) { |stub| stub.invoke(&block) }
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
data/lib/http_stub/version.rb
CHANGED
@@ -186,15 +186,12 @@ describe HttpStub::Configurer::DSL::Server do
|
|
186
186
|
let(:block_verifier) { double("BlockVerifier") }
|
187
187
|
let(:block) { lambda { block_verifier.verify } }
|
188
188
|
|
189
|
-
let(:scenario_builder) { instance_double(HttpStub::Configurer::DSL::ScenarioBuilder) }
|
189
|
+
let(:scenario_builder) { instance_double(HttpStub::Configurer::DSL::ScenarioBuilder, add_stub!: nil) }
|
190
190
|
let(:stub_builder) { instance_double(HttpStub::Configurer::DSL::StubBuilder, invoke: nil) }
|
191
191
|
|
192
|
-
subject { server.add_scenario_with_one_stub!(scenario_name,
|
192
|
+
subject { server.add_scenario_with_one_stub!(scenario_name, stub_builder) }
|
193
193
|
|
194
|
-
before(:each)
|
195
|
-
allow(server).to receive(:add_scenario!).and_yield(scenario_builder)
|
196
|
-
allow(scenario_builder).to receive(:add_stub!).and_yield(stub_builder)
|
197
|
-
end
|
194
|
+
before(:each) { allow(server).to receive(:add_scenario!).and_yield(scenario_builder) }
|
198
195
|
|
199
196
|
it "adds a scenario with the provided name" do
|
200
197
|
expect(server).to receive(:add_scenario!).with(scenario_name)
|
@@ -208,11 +205,34 @@ describe HttpStub::Configurer::DSL::Server do
|
|
208
205
|
subject
|
209
206
|
end
|
210
207
|
|
211
|
-
|
212
|
-
|
213
|
-
|
208
|
+
context "when a builder is provided" do
|
209
|
+
|
210
|
+
subject { server.add_scenario_with_one_stub!(scenario_name, stub_builder) }
|
211
|
+
|
212
|
+
it "adds a stub to the scenario with the provided builder" do
|
213
|
+
expect(scenario_builder).to receive(:add_stub!).with(stub_builder)
|
214
|
+
|
215
|
+
subject
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
219
|
+
|
220
|
+
context "when a block is provided" do
|
221
|
+
|
222
|
+
let(:block_verifier) { double("BlockVerifier") }
|
223
|
+
let(:block) { lambda { block_verifier.verify } }
|
224
|
+
|
225
|
+
subject { server.add_scenario_with_one_stub!(scenario_name, &block) }
|
226
|
+
|
227
|
+
before(:example) { allow(scenario_builder).to receive(:add_stub!).and_yield(stub_builder) }
|
228
|
+
|
229
|
+
it "requests the stub builder invoke the provided block" do
|
230
|
+
expect(stub_builder).to receive(:invoke).and_yield
|
231
|
+
expect(block_verifier).to receive(:verify)
|
232
|
+
|
233
|
+
subject
|
234
|
+
end
|
214
235
|
|
215
|
-
subject
|
216
236
|
end
|
217
237
|
|
218
238
|
end
|