http_stub 0.15.5 → 0.16.0.pre1
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.rb +37 -27
- data/lib/http_stub/configurer.rb +2 -2
- data/lib/http_stub/configurer/dsl/deprecated.rb +60 -0
- data/lib/http_stub/configurer/{server/dsl.rb → dsl/sanctioned.rb} +18 -18
- data/lib/http_stub/configurer/dsl/scenario_activator.rb +15 -0
- data/lib/http_stub/configurer/dsl/scenario_builder.rb +37 -0
- data/lib/http_stub/configurer/dsl/stub_activator_builder.rb +24 -0
- data/lib/http_stub/configurer/{request → dsl}/stub_builder.rb +4 -3
- data/lib/http_stub/configurer/dsl/stub_builder_producer.rb +21 -0
- data/lib/http_stub/configurer/request/http/factory.rb +8 -2
- data/lib/http_stub/configurer/request/scenario.rb +29 -0
- data/lib/http_stub/configurer/server/facade.rb +7 -7
- data/lib/http_stub/server/application.rb +21 -14
- data/lib/http_stub/server/registry.rb +7 -3
- data/lib/http_stub/server/response.rb +3 -3
- data/lib/http_stub/server/scenario.rb +12 -0
- data/lib/http_stub/server/scenario/activator.rb +25 -0
- data/lib/http_stub/server/scenario/controller.rb +36 -0
- data/lib/http_stub/server/scenario/instance.rb +36 -0
- data/lib/http_stub/server/scenario/request_parser.rb +19 -0
- data/lib/http_stub/server/stub.rb +3 -23
- data/lib/http_stub/server/stub/controller.rb +30 -0
- data/lib/http_stub/server/stub/exact_value_matcher.rb +15 -0
- data/lib/http_stub/server/stub/hash_with_string_value_matchers.rb +22 -0
- data/lib/http_stub/server/stub/headers.rb +19 -0
- data/lib/http_stub/server/stub/instance.rb +31 -0
- data/lib/http_stub/server/stub/method.rb +23 -0
- data/lib/http_stub/server/stub/omitted_value_matcher.rb +21 -0
- data/lib/http_stub/server/stub/payload_file_consolidator.rb +18 -0
- data/lib/http_stub/server/stub/regexp_value_matcher.rb +16 -0
- data/lib/http_stub/server/stub/registry.rb +31 -0
- data/lib/http_stub/server/stub/request_header_parser.rb +19 -0
- data/lib/http_stub/server/stub/request_headers.rb +28 -0
- data/lib/http_stub/server/stub/request_parameters.rb +23 -0
- data/lib/http_stub/server/stub/request_parser.rb +17 -0
- data/lib/http_stub/server/stub/response.rb +16 -0
- data/lib/http_stub/server/stub/response/base.rb +64 -0
- data/lib/http_stub/server/stub/response/file.rb +36 -0
- data/lib/http_stub/server/stub/response/text.rb +19 -0
- data/lib/http_stub/server/stub/string_value_matcher.rb +31 -0
- data/lib/http_stub/server/stub/triggers.rb +25 -0
- data/lib/http_stub/server/stub/uri.rb +23 -0
- data/lib/http_stub/server/views/_scenario.haml +16 -0
- data/lib/http_stub/server/views/application.sass +4 -0
- data/lib/http_stub/server/views/scenarios.haml +3 -0
- data/lib/http_stub/version.rb +1 -1
- data/spec/acceptance/activator_spec.rb +81 -0
- data/spec/acceptance/configurer_initialization_spec.rb +158 -0
- data/spec/acceptance/scenario_spec.rb +91 -0
- data/spec/acceptance/stub_control_values_spec.rb +160 -0
- data/spec/acceptance/stub_spec.rb +290 -0
- data/spec/acceptance/stub_trigger_spec.rb +144 -0
- data/spec/lib/http_stub/configurer/{deprecated_dsl_spec.rb → dsl/deprecated_spec.rb} +21 -13
- data/spec/lib/http_stub/configurer/{server/dsl_spec.rb → dsl/sanctioned_spec.rb} +74 -97
- data/spec/lib/http_stub/configurer/dsl/scenario_activator_spec.rb +62 -0
- data/spec/lib/http_stub/configurer/dsl/scenario_builder_spec.rb +146 -0
- data/spec/lib/http_stub/configurer/dsl/stub_activator_builder_spec.rb +120 -0
- data/spec/lib/http_stub/configurer/dsl/stub_builder_producer_spec.rb +105 -0
- data/spec/lib/http_stub/configurer/{request → dsl}/stub_builder_spec.rb +33 -5
- data/spec/lib/http_stub/configurer/request/controllable_value_spec.rb +1 -1
- data/spec/lib/http_stub/configurer/request/http/factory_spec.rb +46 -5
- data/spec/lib/http_stub/configurer/request/omittable_spec.rb +1 -1
- data/spec/lib/http_stub/configurer/request/scenario_spec.rb +69 -0
- data/spec/lib/http_stub/configurer/request/stub_spec.rb +2 -2
- data/spec/lib/http_stub/configurer/server/facade_spec.rb +17 -17
- data/spec/lib/http_stub/configurer_spec.rb +1 -1
- data/spec/lib/http_stub/server/application_integration_spec.rb +23 -13
- data/spec/lib/http_stub/server/application_spec.rb +40 -38
- data/spec/lib/http_stub/server/daemon_spec.rb +2 -2
- data/spec/lib/http_stub/server/registry_spec.rb +66 -17
- data/spec/lib/http_stub/server/{request_parser_spec.rb → request_file_consolidator_spec.rb} +20 -33
- data/spec/lib/http_stub/server/response_pipeline_spec.rb +1 -1
- data/spec/lib/http_stub/server/scenario/activator_spec.rb +106 -0
- data/spec/lib/http_stub/server/scenario/controller_spec.rb +102 -0
- data/spec/lib/http_stub/server/scenario/instance_spec.rb +126 -0
- data/spec/lib/http_stub/server/scenario/request_parser_spec.rb +59 -0
- data/spec/lib/http_stub/server/scenario_spec.rb +24 -0
- data/spec/lib/http_stub/server/{stub_controller_spec.rb → stub/controller_spec.rb} +13 -17
- data/spec/lib/http_stub/server/{exact_value_matcher_spec.rb → stub/exact_value_matcher_spec.rb} +3 -3
- data/spec/lib/http_stub/server/{hash_with_string_value_matchers_spec.rb → stub/hash_with_string_value_matchers_spec.rb} +7 -5
- data/spec/lib/http_stub/server/{headers_spec.rb → stub/headers_spec.rb} +2 -2
- data/spec/lib/http_stub/server/stub/instance_spec.rb +201 -0
- data/spec/lib/http_stub/server/stub/method_spec.rb +95 -0
- data/spec/lib/http_stub/server/{omitted_value_matcher_spec.rb → stub/omitted_value_matcher_spec.rb} +3 -3
- data/spec/lib/http_stub/server/{regexp_value_matcher_spec.rb → stub/regexp_value_matcher_spec.rb} +3 -3
- data/spec/lib/http_stub/server/stub/registry_integration_spec.rb +56 -0
- data/spec/lib/http_stub/server/{stub_registry_spec.rb → stub/registry_spec.rb} +27 -14
- data/spec/lib/http_stub/server/{request_header_parser_spec.rb → stub/request_header_parser_spec.rb} +6 -6
- data/spec/lib/http_stub/server/stub/request_headers_spec.rb +68 -0
- data/spec/lib/http_stub/server/{stub_parameters_spec.rb → stub/request_parameters_spec.rb} +19 -17
- data/spec/lib/http_stub/server/stub/request_parser_spec.rb +56 -0
- data/spec/lib/http_stub/server/{stub_response → stub/response}/base_spec.rb +5 -5
- data/spec/lib/http_stub/server/{stub_response → stub/response}/file_spec.rb +3 -3
- data/spec/lib/http_stub/server/{stub_response → stub/response}/text_spec.rb +3 -3
- data/spec/lib/http_stub/server/{stub_response_spec.rb → stub/response_spec.rb} +8 -8
- data/spec/lib/http_stub/server/{string_value_matcher_spec.rb → stub/string_value_matcher_spec.rb} +25 -13
- data/spec/lib/http_stub/server/{stub_triggers_spec.rb → stub/triggers_spec.rb} +7 -9
- data/spec/lib/http_stub/server/stub/uri_spec.rb +43 -0
- data/spec/lib/http_stub/server/stub_spec.rb +10 -185
- data/spec/spec_helper.rb +10 -5
- data/spec/support/configurer_integration.rb +24 -0
- data/spec/support/scenario_fixture.rb +33 -0
- data/spec/support/stub_fixture.rb +1 -1
- metadata +126 -84
- data/lib/http_stub/configurer/deprecated_dsl.rb +0 -57
- data/lib/http_stub/configurer/request/stub_activator.rb +0 -26
- data/lib/http_stub/configurer/request/stub_activator_builder.rb +0 -25
- data/lib/http_stub/server/exact_value_matcher.rb +0 -13
- data/lib/http_stub/server/hash_with_string_value_matchers.rb +0 -20
- data/lib/http_stub/server/headers.rb +0 -17
- data/lib/http_stub/server/omitted_value_matcher.rb +0 -19
- data/lib/http_stub/server/regexp_value_matcher.rb +0 -14
- data/lib/http_stub/server/request_header_parser.rb +0 -17
- data/lib/http_stub/server/request_parser.rb +0 -29
- data/lib/http_stub/server/string_value_matcher.rb +0 -29
- data/lib/http_stub/server/stub_activator.rb +0 -30
- data/lib/http_stub/server/stub_activator_controller.rb +0 -34
- data/lib/http_stub/server/stub_controller.rb +0 -28
- data/lib/http_stub/server/stub_headers.rb +0 -24
- data/lib/http_stub/server/stub_parameters.rb +0 -21
- data/lib/http_stub/server/stub_registry.rb +0 -29
- data/lib/http_stub/server/stub_response.rb +0 -14
- data/lib/http_stub/server/stub_response/base.rb +0 -62
- data/lib/http_stub/server/stub_response/file.rb +0 -34
- data/lib/http_stub/server/stub_response/text.rb +0 -17
- data/lib/http_stub/server/stub_triggers.rb +0 -23
- data/lib/http_stub/server/stub_uri.rb +0 -21
- data/lib/http_stub/server/views/stub_activators.haml +0 -6
- data/spec/lib/http_stub/configurer/request/stub_activator_builder_spec.rb +0 -119
- data/spec/lib/http_stub/configurer/request/stub_activator_spec.rb +0 -45
- data/spec/lib/http_stub/configurer_integration_spec.rb +0 -837
- data/spec/lib/http_stub/server/stub_activator_controller_spec.rb +0 -95
- data/spec/lib/http_stub/server/stub_activator_spec.rb +0 -83
- data/spec/lib/http_stub/server/stub_headers_spec.rb +0 -68
- data/spec/lib/http_stub/server/stub_registry_integration_spec.rb +0 -62
- data/spec/lib/http_stub/server/stub_uri_spec.rb +0 -42
@@ -1,95 +0,0 @@
|
|
1
|
-
describe HttpStub::Server::StubActivatorController do
|
2
|
-
|
3
|
-
let(:request) { instance_double(Rack::Request) }
|
4
|
-
let(:payload) { HttpStub::StubFixture.new.server_payload.merge("activation_uri" => "/some/activation/uri") }
|
5
|
-
let(:the_stub) { instance_double(HttpStub::Server::Stub) }
|
6
|
-
let(:stub_activator) { instance_double(HttpStub::Server::StubActivator, the_stub: the_stub) }
|
7
|
-
let(:stub_activator_registry) { instance_double(HttpStub::Server::Registry).as_null_object }
|
8
|
-
let(:stub_registry) { instance_double(HttpStub::Server::StubRegistry).as_null_object }
|
9
|
-
|
10
|
-
let(:controller) { HttpStub::Server::StubActivatorController.new(stub_activator_registry, stub_registry) }
|
11
|
-
|
12
|
-
before(:example) do
|
13
|
-
allow(HttpStub::Server::RequestParser).to receive(:parse).and_return(payload)
|
14
|
-
allow(HttpStub::Server::StubActivator).to receive(:new).and_return(stub_activator)
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "#register" do
|
18
|
-
|
19
|
-
subject { controller.register(request) }
|
20
|
-
|
21
|
-
it "parses the payload from the request" do
|
22
|
-
expect(HttpStub::Server::RequestParser).to receive(:parse).with(request).and_return(payload)
|
23
|
-
|
24
|
-
subject
|
25
|
-
end
|
26
|
-
|
27
|
-
it "creates a stub activator with the parsed payload" do
|
28
|
-
expect(HttpStub::Server::StubActivator).to receive(:new).with(payload).and_return(stub_activator)
|
29
|
-
|
30
|
-
subject
|
31
|
-
end
|
32
|
-
|
33
|
-
it "adds the created activator to the activator registry with the provided request" do
|
34
|
-
expect(stub_activator_registry).to receive(:add).with(stub_activator, request)
|
35
|
-
|
36
|
-
subject
|
37
|
-
end
|
38
|
-
|
39
|
-
it "returns a success response" do
|
40
|
-
expect(subject).to eql(HttpStub::Server::Response::SUCCESS)
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "#activate" do
|
46
|
-
|
47
|
-
describe "when a stub activator has been registered that is activated by the request" do
|
48
|
-
|
49
|
-
before(:example) do
|
50
|
-
allow(stub_activator_registry).to receive(:find_for).with(request).and_return(stub_activator)
|
51
|
-
end
|
52
|
-
|
53
|
-
it "adds the activators stub to the stub registry" do
|
54
|
-
expect(stub_registry).to receive(:add).with(the_stub, request)
|
55
|
-
|
56
|
-
controller.activate(request)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "returns a success response" do
|
60
|
-
expect(controller.activate(request)).to eql(HttpStub::Server::Response::SUCCESS)
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
describe "when no stub activator is activated by the request" do
|
66
|
-
|
67
|
-
before(:example) do
|
68
|
-
allow(stub_activator_registry).to receive(:find_for).with(request).and_return(nil)
|
69
|
-
end
|
70
|
-
|
71
|
-
it "does not add a stub to the registry" do
|
72
|
-
expect(stub_registry).not_to receive(:add)
|
73
|
-
|
74
|
-
controller.activate(request)
|
75
|
-
end
|
76
|
-
|
77
|
-
it "returns an empty response" do
|
78
|
-
expect(controller.activate(request)).to eql(HttpStub::Server::Response::EMPTY)
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
describe "#clear" do
|
86
|
-
|
87
|
-
it "clears the activator registry" do
|
88
|
-
expect(stub_activator_registry).to receive(:clear).with(request)
|
89
|
-
|
90
|
-
controller.clear(request)
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
describe HttpStub::Server::StubActivator do
|
2
|
-
|
3
|
-
let(:activation_uri) { "/some/activation/uri" }
|
4
|
-
let(:args) { { "activation_uri" => activation_uri } }
|
5
|
-
let(:underlying_stub) { instance_double(HttpStub::Server::Stub) }
|
6
|
-
|
7
|
-
let(:stub_activator) { HttpStub::Server::StubActivator.new(args) }
|
8
|
-
|
9
|
-
before(:example) { allow(HttpStub::Server::Stub).to receive(:new).and_return(underlying_stub) }
|
10
|
-
|
11
|
-
describe "#constructor" do
|
12
|
-
|
13
|
-
it "creates an underlying stub from the provided arguments" do
|
14
|
-
expect(HttpStub::Server::Stub).to receive(:new).with(args)
|
15
|
-
|
16
|
-
stub_activator
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "#satisfies?" do
|
22
|
-
|
23
|
-
let(:request) { double("HttpRequest", path_info: request_path_info) }
|
24
|
-
|
25
|
-
describe "when the request uri exactly matches the activator's activation uri" do
|
26
|
-
|
27
|
-
let(:request_path_info) { activation_uri }
|
28
|
-
|
29
|
-
it "returns true" do
|
30
|
-
expect(stub_activator.satisfies?(request)).to be_truthy
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "when the activator's activation uri is a substring of the request uri" do
|
36
|
-
|
37
|
-
let(:request_path_info) { "#{activation_uri}/with/additional/paths" }
|
38
|
-
|
39
|
-
it "returns false" do
|
40
|
-
expect(stub_activator.satisfies?(request)).to be_falsey
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "when the request uri is completely different to the activator's activation uri" do
|
46
|
-
|
47
|
-
let(:request_path_info) { "/completely/different/path" }
|
48
|
-
|
49
|
-
it "returns false" do
|
50
|
-
expect(stub_activator.satisfies?(request)).to be_falsey
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
describe "#the_stub" do
|
58
|
-
|
59
|
-
it "returns a HttpStub::Server::Stub constructed from the activator's arguments" do
|
60
|
-
expect(stub_activator.the_stub).to eql(underlying_stub)
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
describe "#activation_uri" do
|
66
|
-
|
67
|
-
it "returns the value provided in the request body" do
|
68
|
-
expect(stub_activator.activation_uri).to eql(activation_uri)
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "#to_s" do
|
74
|
-
|
75
|
-
it "returns the string representation of the activation arguments" do
|
76
|
-
expect(args).to receive(:to_s).and_return("activation args string")
|
77
|
-
|
78
|
-
expect(stub_activator.to_s).to eql("activation args string")
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
describe HttpStub::Server::StubHeaders do
|
2
|
-
|
3
|
-
let(:request) { double("HttpRequest") }
|
4
|
-
let(:stubbed_headers) { { "stub_key" => "value" } }
|
5
|
-
|
6
|
-
let(:stub_headers) { HttpStub::Server::StubHeaders.new(stubbed_headers) }
|
7
|
-
|
8
|
-
it "is Headers" do
|
9
|
-
expect(stub_headers).to be_a(HttpStub::Server::Headers)
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "when stubbed headers are provided" do
|
13
|
-
|
14
|
-
it "creates a regexpable representation of the stubbed headers whose keys are downcased and underscored" do
|
15
|
-
downcased_and_underscored_hash = { "another_stub_key" => "value" }
|
16
|
-
expect(stubbed_headers).to receive(:downcase_and_underscore_keys).and_return(downcased_and_underscored_hash)
|
17
|
-
expect(HttpStub::Server::HashWithStringValueMatchers).to receive(:new).with(downcased_and_underscored_hash)
|
18
|
-
|
19
|
-
stub_headers
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "when the stubbed headers are nil" do
|
25
|
-
|
26
|
-
let(:stubbed_headers) { nil }
|
27
|
-
|
28
|
-
it "creates a regexpable representation of an empty hash" do
|
29
|
-
expect(HttpStub::Server::HashWithStringValueMatchers).to receive(:new).with({})
|
30
|
-
|
31
|
-
stub_headers
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "#match?" do
|
37
|
-
|
38
|
-
let(:request_headers) { { "request_key" => "value" } }
|
39
|
-
let(:regexpable_stubbed_headers) { double(HttpStub::Server::HashWithStringValueMatchers).as_null_object }
|
40
|
-
|
41
|
-
before(:example) do
|
42
|
-
allow(HttpStub::Server::HashWithStringValueMatchers).to receive(:new).and_return(regexpable_stubbed_headers)
|
43
|
-
allow(HttpStub::Server::RequestHeaderParser).to receive(:parse).with(request).and_return(request_headers)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "parses the requests headers into a hash" do
|
47
|
-
expect(HttpStub::Server::RequestHeaderParser).to receive(:parse).with(request).and_return(request_headers)
|
48
|
-
|
49
|
-
stub_headers.match?(request)
|
50
|
-
end
|
51
|
-
|
52
|
-
it "downcases and underscore the keys in the request header hash" do
|
53
|
-
expect(request_headers).to receive(:downcase_and_underscore_keys)
|
54
|
-
|
55
|
-
stub_headers.match?(request)
|
56
|
-
end
|
57
|
-
|
58
|
-
it "delegates to the regexpable representation of the stubbed headers to determine a match" do
|
59
|
-
downcased_and_underscored_hash = { "another_request_key" => "value" }
|
60
|
-
allow(request_headers).to receive(:downcase_and_underscore_keys).and_return(downcased_and_underscored_hash)
|
61
|
-
expect(regexpable_stubbed_headers).to receive(:match?).with(downcased_and_underscored_hash).and_return(true)
|
62
|
-
|
63
|
-
expect(stub_headers.match?(request)).to be_truthy
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
describe HttpStub::Server::StubRegistry, "integrating with real stubs" do
|
2
|
-
|
3
|
-
let(:logger) { double("Logger").as_null_object }
|
4
|
-
let(:request) { double("HttpRequest", logger: logger) }
|
5
|
-
|
6
|
-
let(:stub_registry) { HttpStub::Server::StubRegistry.new }
|
7
|
-
|
8
|
-
describe "#recall" do
|
9
|
-
|
10
|
-
subject { stub_registry.recall }
|
11
|
-
|
12
|
-
context "when stubs have been added" do
|
13
|
-
|
14
|
-
let(:stubs) do
|
15
|
-
(1..3).map { |i| create_stub(i) }
|
16
|
-
end
|
17
|
-
|
18
|
-
before(:example) do
|
19
|
-
stubs.each { |stub| stub_registry.add(stub, request) }
|
20
|
-
end
|
21
|
-
|
22
|
-
context "and remembered" do
|
23
|
-
|
24
|
-
before(:example) { stub_registry.remember }
|
25
|
-
|
26
|
-
context "and a stub subsequently added" do
|
27
|
-
|
28
|
-
let(:stub_to_add) { create_stub(4) }
|
29
|
-
|
30
|
-
before(:example) { stub_registry.add(stub_to_add, request) }
|
31
|
-
|
32
|
-
it "should restore all known stubs to the remembered state" do
|
33
|
-
subject
|
34
|
-
|
35
|
-
expect(stub_registry.all).not_to include(stub_to_add)
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
def create_stub(number)
|
47
|
-
HttpStub::Server::Stub.new(
|
48
|
-
{
|
49
|
-
"uri" => "/uri#{number}",
|
50
|
-
"method" => "get",
|
51
|
-
"headers" => {"header_key_#{number}" => "header_value_#{number}"},
|
52
|
-
"parameters" => {"parameter_key_#{number}" => "parameter_value_#{number}"},
|
53
|
-
"response" => {
|
54
|
-
"status" => 200 + number,
|
55
|
-
"body" => "Body #{number}"
|
56
|
-
},
|
57
|
-
"triggers" => []
|
58
|
-
}
|
59
|
-
)
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
describe HttpStub::Server::StubUri do
|
2
|
-
|
3
|
-
let(:stubbed_uri) { "/some/uri" }
|
4
|
-
let(:request) { double("HttpRequest", path_info: request_uri) }
|
5
|
-
let(:value_matcher) { double(HttpStub::Server::StringValueMatcher).as_null_object }
|
6
|
-
let(:stub_uri) { HttpStub::Server::StubUri.new(stubbed_uri) }
|
7
|
-
|
8
|
-
before(:example) { allow(HttpStub::Server::StringValueMatcher).to receive(:new).and_return(value_matcher) }
|
9
|
-
|
10
|
-
describe "constructor" do
|
11
|
-
|
12
|
-
it "creates a value matcher for the provided uri" do
|
13
|
-
expect(HttpStub::Server::StringValueMatcher).to receive(:new).with(stubbed_uri)
|
14
|
-
|
15
|
-
stub_uri
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "#match?" do
|
21
|
-
|
22
|
-
let(:request_uri) { "/some/uri" }
|
23
|
-
|
24
|
-
it "delegates to the value matcher representation of the provided uri" do
|
25
|
-
expect(value_matcher).to receive(:match?).with(request_uri).and_return(true)
|
26
|
-
|
27
|
-
expect(stub_uri.match?(request)).to be_truthy
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "#to_s" do
|
33
|
-
|
34
|
-
it "delegates to the value matcher representation of the provided uri" do
|
35
|
-
expect(value_matcher).to receive(:to_s).and_return("some value matcher string")
|
36
|
-
|
37
|
-
expect(stub_uri.to_s).to eql("some value matcher string")
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|