http_stub 0.28.0.beta2 → 0.28.0
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/configurator/endpoint_template.rb +1 -1
- data/lib/http_stub/configurator/server.rb +3 -1
- data/lib/http_stub/version.rb +1 -1
- data/spec/acceptance/endpoint_template_spec.rb +7 -0
- data/spec/lib/http_stub/configurator/endpoint_template_spec.rb +5 -5
- data/spec/lib/http_stub/configurator/server_spec.rb +52 -3
- data/spec/support/http_stub/server/driver.rb +1 -1
- metadata +8 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36a7a947b8f803c0ec1851b4e646d6c579bed2765195b7277a809b6a7500c895
|
4
|
+
data.tar.gz: 55e0b0a5ae19f81277e5c0c8fac67d58c0f2936b1a6240e03537f0090036fad1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0202cba44793df890e435672550795d988f13614471e9220eb1796965237e080ffeccd6cb54e62a8cc1ffe75684711b9ce80abeb662503c42130f9292d1624eb
|
7
|
+
data.tar.gz: ca13e5950fa73d3a5ff6dce748b37a4ef93f071dec782f46cea0ba71a00fb7fc3d08aa8ef47c3926df84a94f22d59c9839d0594704f3d5c23cea8a5b5f635137
|
@@ -11,7 +11,7 @@ module HttpStub
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def add_scenario!(name, response_overrides={}, &block)
|
14
|
-
@server.add_scenario_with_one_stub!(name, self.build_stub(response_overrides, &block)
|
14
|
+
@server.add_scenario_with_one_stub!(name, self.build_stub(response_overrides), &block)
|
15
15
|
end
|
16
16
|
|
17
17
|
def add_stub!(response_overrides={}, &block)
|
@@ -34,7 +34,9 @@ module HttpStub
|
|
34
34
|
|
35
35
|
def add_scenario_with_one_stub!(name, stub=nil, &block)
|
36
36
|
add_scenario!(name) do |scenario|
|
37
|
-
|
37
|
+
built_stub = stub || scenario.build_stub
|
38
|
+
built_stub.invoke(block.arity == 2 ? scenario : nil, &block) if block_given?
|
39
|
+
scenario.add_stub!(built_stub)
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
data/lib/http_stub/version.rb
CHANGED
@@ -18,6 +18,13 @@ describe "Endpoint template acceptance" do
|
|
18
18
|
expect(response.body).to eql("custom stub body")
|
19
19
|
end
|
20
20
|
|
21
|
+
it "registers any stubs for templated scenarios initially activated" do
|
22
|
+
response = issue_request("scenario_initially_activated")
|
23
|
+
|
24
|
+
expect(response.code).to eql(202)
|
25
|
+
expect(response.body).to eql("scenario initially activated body")
|
26
|
+
end
|
27
|
+
|
21
28
|
context "and a templated scenario is activated" do
|
22
29
|
|
23
30
|
before(:example) { client.activate!(scenario_name) }
|
@@ -130,15 +130,15 @@ describe HttpStub::Configurator::EndpointTemplate do
|
|
130
130
|
allow(server).to receive(:add_scenario_with_one_stub!)
|
131
131
|
end
|
132
132
|
|
133
|
-
it "builds a stub using any provided response overrides
|
134
|
-
expect(endpoint_stub_template).to receive(:build_stub).with(response_overrides)
|
135
|
-
expect(block_verifier).to receive(:verify)
|
133
|
+
it "builds a stub using any provided response overrides" do
|
134
|
+
expect(endpoint_stub_template).to receive(:build_stub).with(response_overrides)
|
136
135
|
|
137
136
|
subject
|
138
137
|
end
|
139
138
|
|
140
|
-
it "adds a one stub scenario to the server with the provided name
|
141
|
-
expect(server).to receive(:add_scenario_with_one_stub!).with(name, built_stub)
|
139
|
+
it "adds a one stub scenario to the server with the provided name, built stub and block" do
|
140
|
+
expect(server).to receive(:add_scenario_with_one_stub!).with(name, built_stub).and_yield
|
141
|
+
expect(block_verifier).to receive(:verify)
|
142
142
|
|
143
143
|
subject
|
144
144
|
end
|
@@ -211,14 +211,23 @@ describe HttpStub::Configurator::Server do
|
|
211
211
|
|
212
212
|
subject { server.add_scenario_with_one_stub!(scenario_name, &block) }
|
213
213
|
|
214
|
-
before(:example)
|
214
|
+
before(:example) do
|
215
|
+
allow(scenario).to receive(:build_stub).and_return(the_stub)
|
216
|
+
allow(scenario).to receive(:add_stub!)
|
217
|
+
end
|
215
218
|
|
216
|
-
it "
|
217
|
-
expect(scenario).to receive(:
|
219
|
+
it "builds a stub from the scenario" do
|
220
|
+
expect(scenario).to receive(:build_stub).with(no_args)
|
218
221
|
|
219
222
|
subject
|
220
223
|
end
|
221
224
|
|
225
|
+
it "adds the built stub to the scenario" do
|
226
|
+
expect(scenario).to receive(:add_stub!).with(the_stub)
|
227
|
+
|
228
|
+
subject
|
229
|
+
end
|
230
|
+
|
222
231
|
context "that accepts the stub as an argument" do
|
223
232
|
|
224
233
|
let(:block) { lambda { |_stub| block_verifier.verify } }
|
@@ -247,6 +256,46 @@ describe HttpStub::Configurator::Server do
|
|
247
256
|
|
248
257
|
end
|
249
258
|
|
259
|
+
context "when a stub and block is provided" do
|
260
|
+
|
261
|
+
subject { server.add_scenario_with_one_stub!(scenario_name, the_stub, &block) }
|
262
|
+
|
263
|
+
before(:example) { allow(scenario).to receive(:add_stub!) }
|
264
|
+
|
265
|
+
it "adds the stub to the scenario" do
|
266
|
+
expect(scenario).to receive(:add_stub!).with(the_stub)
|
267
|
+
|
268
|
+
subject
|
269
|
+
end
|
270
|
+
|
271
|
+
context "and the block accepts the stub as an argument" do
|
272
|
+
|
273
|
+
let(:block) { lambda { |_stub| block_verifier.verify } }
|
274
|
+
|
275
|
+
it "invokes the stub with no additional argument" do
|
276
|
+
expect(the_stub).to receive(:invoke).with(nil).and_yield(the_stub)
|
277
|
+
expect(block_verifier).to receive(:verify)
|
278
|
+
|
279
|
+
subject
|
280
|
+
end
|
281
|
+
|
282
|
+
end
|
283
|
+
|
284
|
+
context "and the block accepts the stub and scenario as arguments" do
|
285
|
+
|
286
|
+
let(:block) { lambda { |_stub, _scenario| block_verifier.verify } }
|
287
|
+
|
288
|
+
it "invokes the stub and supplies the scenario" do
|
289
|
+
expect(the_stub).to receive(:invoke).with(scenario).and_yield(the_stub, scenario)
|
290
|
+
expect(block_verifier).to receive(:verify)
|
291
|
+
|
292
|
+
subject
|
293
|
+
end
|
294
|
+
|
295
|
+
end
|
296
|
+
|
297
|
+
end
|
298
|
+
|
250
299
|
end
|
251
300
|
|
252
301
|
describe "#build_stub" do
|
@@ -34,7 +34,7 @@ module HttpStub
|
|
34
34
|
@port = HttpStub::Port.free_port
|
35
35
|
@pid = Process.spawn("rake launch_server configurator=#{@configurator.name} port=#{@port}", out: DEV_NULL,
|
36
36
|
err: DEV_NULL)
|
37
|
-
::Wait.until!(description: "http stub server for #{@configurator.name} started", timeout_in_seconds:
|
37
|
+
::Wait.until!(description: "http stub server for #{@configurator.name} started", timeout_in_seconds: 5) do
|
38
38
|
Net::HTTP.get_response(@host, "/http_stub/status", @port)
|
39
39
|
@uri = "http://#{@host}:#{@port}"
|
40
40
|
@client = HttpStub::Client.create(@uri)
|
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.28.0
|
4
|
+
version: 0.28.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dueckes
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2019-06-
|
15
|
+
date: 2019-06-27 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rake
|
@@ -160,14 +160,14 @@ dependencies:
|
|
160
160
|
requirements:
|
161
161
|
- - "~>"
|
162
162
|
- !ruby/object:Gem::Version
|
163
|
-
version: '0.
|
163
|
+
version: '0.72'
|
164
164
|
type: :development
|
165
165
|
prerelease: false
|
166
166
|
version_requirements: !ruby/object:Gem::Requirement
|
167
167
|
requirements:
|
168
168
|
- - "~>"
|
169
169
|
- !ruby/object:Gem::Version
|
170
|
-
version: '0.
|
170
|
+
version: '0.72'
|
171
171
|
- !ruby/object:Gem::Dependency
|
172
172
|
name: rspec
|
173
173
|
requirement: !ruby/object:Gem::Requirement
|
@@ -258,28 +258,14 @@ dependencies:
|
|
258
258
|
requirements:
|
259
259
|
- - "~>"
|
260
260
|
- !ruby/object:Gem::Version
|
261
|
-
version: 0.
|
261
|
+
version: '0.16'
|
262
262
|
type: :development
|
263
263
|
prerelease: false
|
264
264
|
version_requirements: !ruby/object:Gem::Requirement
|
265
265
|
requirements:
|
266
266
|
- - "~>"
|
267
267
|
- !ruby/object:Gem::Version
|
268
|
-
version: 0.
|
269
|
-
- !ruby/object:Gem::Dependency
|
270
|
-
name: codeclimate-test-reporter
|
271
|
-
requirement: !ruby/object:Gem::Requirement
|
272
|
-
requirements:
|
273
|
-
- - "~>"
|
274
|
-
- !ruby/object:Gem::Version
|
275
|
-
version: '1.0'
|
276
|
-
type: :development
|
277
|
-
prerelease: false
|
278
|
-
version_requirements: !ruby/object:Gem::Requirement
|
279
|
-
requirements:
|
280
|
-
- - "~>"
|
281
|
-
- !ruby/object:Gem::Version
|
282
|
-
version: '1.0'
|
268
|
+
version: '0.16'
|
283
269
|
- !ruby/object:Gem::Dependency
|
284
270
|
name: travis-lint
|
285
271
|
requirement: !ruby/object:Gem::Requirement
|
@@ -594,9 +580,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
594
580
|
version: '2.3'
|
595
581
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
596
582
|
requirements:
|
597
|
-
- - "
|
583
|
+
- - ">="
|
598
584
|
- !ruby/object:Gem::Version
|
599
|
-
version:
|
585
|
+
version: '0'
|
600
586
|
requirements: []
|
601
587
|
rubygems_version: 3.0.4
|
602
588
|
signing_key:
|