http_stub 0.22.3 → 0.22.4
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 +4 -4
- data/lib/http_stub/configurer/dsl/server.rb +4 -0
- data/lib/http_stub/server/application.rb +1 -1
- data/lib/http_stub/server/stub/controller.rb +1 -1
- data/lib/http_stub/version.rb +1 -1
- data/spec/acceptance/scenario_spec.rb +1 -1
- data/spec/acceptance/stub_body_request_matching_spec.rb +3 -3
- data/spec/acceptance/stub_match_spec.rb +1 -1
- data/spec/lib/http_stub/configurer/dsl/endpoint_template_spec.rb +1 -1
- data/spec/lib/http_stub/configurer/dsl/server_spec.rb +47 -4
- data/spec/lib/http_stub/server/application_spec.rb +3 -3
- data/spec/lib/http_stub/server/stub/controller_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74144ffbb6dae5921a1631ba6a219e0fbc4bdff7
|
4
|
+
data.tar.gz: e789bd03754aeb44631801f7154a9585d7f08842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73947db83ba0eb75d7b40028c3f1868f77aa34123d6ef8822e39648062312d21fbe4eec0331df59b095078373d99f9b7e5b2a076e880c0dca27d77e7bdb6b62b
|
7
|
+
data.tar.gz: f715347c8d45c0109c25ec08d704797301b2d8b803ab15c64d4a21d37e736effa4fb7cb27c5a5f615db32491e7724019cfe2f67abb7f88be91f1672e99f91550
|
@@ -14,7 +14,7 @@ module HttpStub
|
|
14
14
|
HttpStub::Server::Response.success("location" => stub.stub_uri)
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def match(request, logger)
|
18
18
|
stub = @registry.match(request, logger)
|
19
19
|
stub ? stub.response : HttpStub::Server::Response::NOT_FOUND
|
20
20
|
end
|
data/lib/http_stub/version.rb
CHANGED
@@ -32,7 +32,7 @@ describe "Scenario acceptance" do
|
|
32
32
|
|
33
33
|
context "containing triggered scenarios" do
|
34
34
|
|
35
|
-
before(:example) { configurer.activate!("
|
35
|
+
before(:example) { configurer.activate!("Activates another scenario") }
|
36
36
|
|
37
37
|
(1..3).each do |stub_number|
|
38
38
|
|
@@ -9,7 +9,7 @@ describe "Scenario acceptance" do
|
|
9
9
|
|
10
10
|
context "against an exact match" do
|
11
11
|
|
12
|
-
before(:example) { stub_server.activate!("
|
12
|
+
before(:example) { stub_server.activate!("Match body exactly") }
|
13
13
|
|
14
14
|
context "and a request is made with a request body" do
|
15
15
|
|
@@ -53,7 +53,7 @@ describe "Scenario acceptance" do
|
|
53
53
|
|
54
54
|
context "against a regular expression" do
|
55
55
|
|
56
|
-
before(:example) { stub_server.activate!("
|
56
|
+
before(:example) { stub_server.activate!("Match body regex") }
|
57
57
|
|
58
58
|
context "and a request is made with a request body" do
|
59
59
|
|
@@ -97,7 +97,7 @@ describe "Scenario acceptance" do
|
|
97
97
|
|
98
98
|
context "against a JSON schema" do
|
99
99
|
|
100
|
-
before(:example) { stub_server.activate!("
|
100
|
+
before(:example) { stub_server.activate!("Match body JSON schema") }
|
101
101
|
|
102
102
|
context "and a request is made with a request body" do
|
103
103
|
|
@@ -225,7 +225,7 @@ describe HttpStub::Configurer::DSL::EndpointTemplate do
|
|
225
225
|
|
226
226
|
describe "#add_scenario!" do
|
227
227
|
|
228
|
-
let(:name) { "
|
228
|
+
let(:name) { "Some scenario name" }
|
229
229
|
let(:stub_builder) { instance_double(HttpStub::Configurer::DSL::StubBuilder).as_null_object }
|
230
230
|
|
231
231
|
before(:example) { allow(server).to receive(:add_scenario_with_one_stub!).and_yield(stub_builder) }
|
@@ -9,6 +9,15 @@ describe HttpStub::Configurer::DSL::Server do
|
|
9
9
|
allow(HttpStub::Configurer::DSL::StubBuilder).to receive(:new).with(no_args).and_return(default_stub_builder)
|
10
10
|
end
|
11
11
|
|
12
|
+
shared_context "a server with host and port configured" do
|
13
|
+
|
14
|
+
before(:example) do
|
15
|
+
server.host = "some_host"
|
16
|
+
server.port = 8888
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
12
21
|
it "produces stub builders" do
|
13
22
|
expect(server).to be_a(HttpStub::Configurer::DSL::StubBuilderProducer)
|
14
23
|
end
|
@@ -21,9 +30,43 @@ describe HttpStub::Configurer::DSL::Server do
|
|
21
30
|
|
22
31
|
subject { server.base_uri }
|
23
32
|
|
24
|
-
|
25
|
-
|
26
|
-
|
33
|
+
include_context "a server with host and port configured"
|
34
|
+
|
35
|
+
it "returns a uri that combines any established host and port" do
|
36
|
+
expect(subject).to include("some_host:8888")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns a uri accessed via http" do
|
40
|
+
expect(subject).to match(/^http:\/\//)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#external_base_uri" do
|
46
|
+
|
47
|
+
subject { server.external_base_uri }
|
48
|
+
|
49
|
+
include_context "a server with host and port configured"
|
50
|
+
|
51
|
+
context "when an external base URI environment variable is established" do
|
52
|
+
|
53
|
+
let(:external_base_uri) { "http://some/external/base/uri" }
|
54
|
+
|
55
|
+
before(:example) { ENV["STUB_EXTERNAL_BASE_URI"] = external_base_uri }
|
56
|
+
after(:example) { ENV["STUB_EXTERNAL_BASE_URI"] = nil }
|
57
|
+
|
58
|
+
it "returns the environment variable" do
|
59
|
+
expect(subject).to eql(external_base_uri)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
context "when an external base URI environment variable is not established" do
|
65
|
+
|
66
|
+
it "returns the base URI" do
|
67
|
+
expect(subject).to eql(server.base_uri)
|
68
|
+
end
|
69
|
+
|
27
70
|
end
|
28
71
|
|
29
72
|
it "returns a uri that combines any established host and port" do
|
@@ -182,7 +225,7 @@ describe HttpStub::Configurer::DSL::Server do
|
|
182
225
|
|
183
226
|
describe "#add_scenario_with_one_stub!" do
|
184
227
|
|
185
|
-
let(:scenario_name) { "
|
228
|
+
let(:scenario_name) { "Some scenario name" }
|
186
229
|
let(:block_verifier) { double("BlockVerifier") }
|
187
230
|
let(:block) { lambda { block_verifier.verify } }
|
188
231
|
|
@@ -282,10 +282,10 @@ describe HttpStub::Server::Application do
|
|
282
282
|
|
283
283
|
subject { get "/a_path" }
|
284
284
|
|
285
|
-
before(:example) { allow(stub_controller).to receive(:
|
285
|
+
before(:example) { allow(stub_controller).to receive(:match).and_return(stub_response) }
|
286
286
|
|
287
|
-
it "attempts to
|
288
|
-
expect(stub_controller).to receive(:
|
287
|
+
it "attempts to match the request to a stub response via the stub controller" do
|
288
|
+
expect(stub_controller).to receive(:match).with(an_instance_of(HttpStub::Server::Request), anything)
|
289
289
|
|
290
290
|
subject
|
291
291
|
end
|
@@ -52,9 +52,9 @@ describe HttpStub::Server::Stub::Controller do
|
|
52
52
|
|
53
53
|
end
|
54
54
|
|
55
|
-
describe "#
|
55
|
+
describe "#match" do
|
56
56
|
|
57
|
-
subject { controller.
|
57
|
+
subject { controller.match(request, logger) }
|
58
58
|
|
59
59
|
before(:example) { allow(registry).to receive(:match).with(request, logger).and_return(matched_stub) }
|
60
60
|
|
data/spec/spec_helper.rb
CHANGED
@@ -27,9 +27,9 @@ require_relative '../examples/configurer_with_server_defaults'
|
|
27
27
|
require_relative '../examples/configurer_with_stub_triggers'
|
28
28
|
require_relative '../examples/configurer_with_file_responses'
|
29
29
|
require_relative '../examples/configurer_with_stub_request_body'
|
30
|
-
require_relative '../examples/configurer_with_regex_request_body'
|
31
30
|
require_relative '../examples/configurer_with_parts'
|
32
31
|
require_relative '../examples/configurer_with_endpoint_template'
|
32
|
+
require_relative '../examples/authentication_service/configurer'
|
33
33
|
|
34
34
|
HttpStub::Server::Daemon.log_dir = ::File.expand_path('../../tmp/log', __FILE__)
|
35
35
|
HttpStub::Server::Daemon.pid_dir = ::File.expand_path('../../tmp/pids', __FILE__)
|
metadata
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_stub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.22.
|
4
|
+
version: 0.22.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
-
|
7
|
+
- dueckes
|
8
|
+
- rvanbert
|
9
|
+
- rypac
|
10
|
+
- andykingking
|
11
|
+
- campezzi
|
9
12
|
autorequire:
|
10
13
|
bindir: bin
|
11
14
|
cert_chain: []
|
12
|
-
date: 2016-05-
|
15
|
+
date: 2016-05-13 00:00:00.000000000 Z
|
13
16
|
dependencies:
|
14
17
|
- !ruby/object:Gem::Dependency
|
15
18
|
name: rake
|
@@ -481,7 +484,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
481
484
|
version: '0'
|
482
485
|
requirements: []
|
483
486
|
rubyforge_project: http_stub
|
484
|
-
rubygems_version: 2.
|
487
|
+
rubygems_version: 2.5.1
|
485
488
|
signing_key:
|
486
489
|
specification_version: 4
|
487
490
|
summary: A HTTP Server replaying configured stub responses
|