http_stub 0.22.3 → 0.22.4

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: 4c80f3899b852c169dc4f860759ae6c096e29fdb
4
- data.tar.gz: 4a56c16de077939fb79a6152f4d98dcf7ff1c6b7
3
+ metadata.gz: 74144ffbb6dae5921a1631ba6a219e0fbc4bdff7
4
+ data.tar.gz: e789bd03754aeb44631801f7154a9585d7f08842
5
5
  SHA512:
6
- metadata.gz: 3940ab6caac7e382d473acefc9fa09e8f3232b56ae5430df606bd50761a081c1962d5f1321d2ff8582e027e7e33d588e67eaf67e3b94edac705a4556cb669214
7
- data.tar.gz: 4aea566a355af20b43c457819319cd22ed412d5555fb7a76d77a5f797857899ce334adfb8d834c576fe6bb5d2e22c5cc3cd9acaacead541cefd67b696aefda35
6
+ metadata.gz: 73947db83ba0eb75d7b40028c3f1868f77aa34123d6ef8822e39648062312d21fbe4eec0331df59b095078373d99f9b7e5b2a076e880c0dca27d77e7bdb6b62b
7
+ data.tar.gz: f715347c8d45c0109c25ec08d704797301b2d8b803ab15c64d4a21d37e736effa4fb7cb27c5a5f615db32491e7724019cfe2f67abb7f88be91f1672e99f91550
@@ -17,6 +17,10 @@ module HttpStub
17
17
  "http://#{host}:#{port}"
18
18
  end
19
19
 
20
+ def external_base_uri
21
+ ENV["STUB_EXTERNAL_BASE_URI"] || base_uri
22
+ end
23
+
20
24
  def request_defaults=(args)
21
25
  @default_stub_builder.match_requests(args)
22
26
  end
@@ -99,7 +99,7 @@ module HttpStub
99
99
  end
100
100
 
101
101
  any_request_type(//) do
102
- response = @stub_controller.replay(@http_stub_request, logger)
102
+ response = @stub_controller.match(@http_stub_request, logger)
103
103
  @response_pipeline.process(response)
104
104
  end
105
105
 
@@ -14,7 +14,7 @@ module HttpStub
14
14
  HttpStub::Server::Response.success("location" => stub.stub_uri)
15
15
  end
16
16
 
17
- def replay(request, logger)
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
@@ -1,3 +1,3 @@
1
1
  module HttpStub
2
- VERSION = "0.22.3".freeze
2
+ VERSION = "0.22.4".freeze
3
3
  end
@@ -32,7 +32,7 @@ describe "Scenario acceptance" do
32
32
 
33
33
  context "containing triggered scenarios" do
34
34
 
35
- before(:example) { configurer.activate!("Scenario that activates another scenario") }
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!("match_body_exactly_scenario") }
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!("match_body_regex_scenario") }
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!("match_body_json_schema_scenario") }
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
 
@@ -173,7 +173,7 @@ describe "Stub match acceptance" do
173
173
  end
174
174
 
175
175
  def register_scenario
176
- stub_server.add_scenario_with_one_stub!("some_scenario", build_stub)
176
+ stub_server.add_scenario_with_one_stub!("Some scenario", build_stub)
177
177
  end
178
178
 
179
179
  end
@@ -225,7 +225,7 @@ describe HttpStub::Configurer::DSL::EndpointTemplate do
225
225
 
226
226
  describe "#add_scenario!" do
227
227
 
228
- let(:name) { "some_scenario_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
- before(:example) do
25
- server.host = "some_host"
26
- server.port = 8888
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) { "some_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(:replay).and_return(stub_response) }
285
+ before(:example) { allow(stub_controller).to receive(:match).and_return(stub_response) }
286
286
 
287
- it "attempts to replay a stub response via the stub controller" do
288
- expect(stub_controller).to receive(:replay).with(an_instance_of(HttpStub::Server::Request), anything)
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 "#replay" do
55
+ describe "#match" do
56
56
 
57
- subject { controller.replay(request, logger) }
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
 
@@ -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.3
4
+ version: 0.22.4
5
5
  platform: ruby
6
6
  authors:
7
- - Matthew Ueckerman
8
- - Russell Van Bert
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-05 00:00:00.000000000 Z
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.4.6
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