http_stub 0.13.5 → 0.14.0.rc1
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.rb +13 -4
- data/lib/http_stub/configurer.rb +9 -63
- data/lib/http_stub/configurer/deprecated_dsl.rb +57 -0
- data/lib/http_stub/configurer/request/stub.rb +7 -13
- data/lib/http_stub/configurer/request/stub_activator.rb +8 -4
- data/lib/http_stub/configurer/request/stub_activator_payload_builder.rb +25 -0
- data/lib/http_stub/configurer/request/stub_payload_builder.rb +44 -0
- data/lib/http_stub/configurer/server/buffered_command_processor.rb +24 -0
- data/lib/http_stub/configurer/server/command.rb +18 -0
- data/lib/http_stub/configurer/server/command_processor.rb +38 -0
- data/lib/http_stub/configurer/server/dsl.rb +56 -0
- data/lib/http_stub/configurer/server/facade.rb +57 -0
- data/lib/http_stub/configurer/server/request_processor.rb +30 -0
- data/lib/http_stub/models/registry.rb +4 -0
- data/lib/http_stub/models/stub.rb +2 -1
- data/lib/http_stub/models/stub_registry.rb +29 -0
- data/lib/http_stub/models/stub_triggers.rb +23 -0
- data/lib/http_stub/rake/server_tasks.rb +2 -5
- data/lib/http_stub/server.rb +14 -4
- data/lib/http_stub/version.rb +1 -1
- data/lib/http_stub/views/_stub.haml +7 -0
- data/spec/lib/http_stub/configurer/deprecated_dsl_spec.rb +232 -0
- data/spec/lib/http_stub/configurer/request/controllable_value_spec.rb +8 -8
- data/spec/lib/http_stub/configurer/request/omittable_spec.rb +8 -8
- data/spec/lib/http_stub/configurer/request/regexpable_spec.rb +14 -14
- data/spec/lib/http_stub/configurer/request/stub_activator_payload_builder_spec.rb +74 -0
- data/spec/lib/http_stub/configurer/request/stub_activator_spec.rb +19 -26
- data/spec/lib/http_stub/configurer/request/stub_payload_builder_spec.rb +203 -0
- data/spec/lib/http_stub/configurer/request/stub_spec.rb +18 -157
- data/spec/lib/http_stub/configurer/server/buffered_command_processor_spec.rb +35 -0
- data/spec/lib/http_stub/configurer/server/command_processor_integration_spec.rb +62 -0
- data/spec/lib/http_stub/configurer/server/command_spec.rb +25 -0
- data/spec/lib/http_stub/configurer/server/dsl_spec.rb +241 -0
- data/spec/lib/http_stub/configurer/server/facade_spec.rb +253 -0
- data/spec/lib/http_stub/configurer/server/request_processor_spec.rb +99 -0
- data/spec/lib/http_stub/configurer_integration_spec.rb +172 -122
- data/spec/lib/http_stub/configurer_spec.rb +4 -4
- data/spec/lib/http_stub/controllers/stub_activator_controller_spec.rb +25 -25
- data/spec/lib/http_stub/controllers/stub_controller_spec.rb +22 -22
- data/spec/lib/http_stub/hash_extensions_spec.rb +24 -24
- data/spec/lib/http_stub/models/exact_value_matcher_spec.rb +4 -4
- data/spec/lib/http_stub/models/hash_with_string_value_matchers_spec.rb +29 -29
- data/spec/lib/http_stub/models/headers_spec.rb +10 -10
- data/spec/lib/http_stub/models/omitted_value_matcher_spec.rb +8 -8
- data/spec/lib/http_stub/models/regexp_value_matcher_spec.rb +6 -6
- data/spec/lib/http_stub/models/registry_spec.rb +71 -28
- data/spec/lib/http_stub/models/request_header_parser_spec.rb +4 -4
- data/spec/lib/http_stub/models/request_pipeline_spec.rb +2 -2
- data/spec/lib/http_stub/models/response_spec.rb +38 -38
- data/spec/lib/http_stub/models/string_value_matcher_spec.rb +25 -25
- data/spec/lib/http_stub/models/stub_activator_spec.rb +15 -15
- data/spec/lib/http_stub/models/stub_headers_spec.rb +18 -18
- data/spec/lib/http_stub/models/stub_parameters_spec.rb +16 -16
- data/spec/lib/http_stub/models/stub_registry_integration_spec.rb +62 -0
- data/spec/lib/http_stub/models/stub_registry_spec.rb +152 -0
- data/spec/lib/http_stub/models/stub_spec.rb +67 -43
- data/spec/lib/http_stub/models/stub_triggers_spec.rb +64 -0
- data/spec/lib/http_stub/models/stub_uri_spec.rb +9 -9
- data/spec/lib/http_stub/rake/server_daemon_tasks_smoke_spec.rb +7 -7
- data/spec/lib/http_stub/rake/server_tasks_smoke_spec.rb +5 -5
- data/spec/lib/http_stub/rake/server_tasks_spec.rb +17 -15
- data/spec/lib/http_stub/server_daemon_spec.rb +16 -16
- data/spec/lib/http_stub/server_integration_spec.rb +112 -65
- data/spec/lib/http_stub/server_spec.rb +134 -96
- data/spec/spec_helper.rb +1 -1
- data/spec/support/http_stub/configurer/request/stub_payload_builder_shared_context.rb +27 -0
- data/spec/support/server_integration.rb +2 -2
- metadata +69 -30
- data/lib/http_stub/configurer/command.rb +0 -26
- data/lib/http_stub/configurer/command_processor.rb +0 -36
- data/lib/http_stub/configurer/impatient_command_chain.rb +0 -13
- data/lib/http_stub/configurer/patient_command_chain.rb +0 -25
- data/spec/lib/http_stub/configurer/command_processor_integration_spec.rb +0 -63
- data/spec/lib/http_stub/configurer/command_spec.rb +0 -40
- data/spec/lib/http_stub/configurer/impatient_command_chain_spec.rb +0 -17
- data/spec/lib/http_stub/configurer/patient_command_chain_spec.rb +0 -73
@@ -9,12 +9,12 @@ describe HttpStub::Configurer do
|
|
9
9
|
|
10
10
|
describe ".get_base_uri" do
|
11
11
|
|
12
|
-
it "
|
13
|
-
TestableConfigurer.get_base_uri.
|
12
|
+
it "returns a uri that combines the provided host and port" do
|
13
|
+
expect(TestableConfigurer.get_base_uri).to include("some_host:8888")
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
17
|
-
TestableConfigurer.get_base_uri.
|
16
|
+
it "returns a uri accessed via http" do
|
17
|
+
expect(TestableConfigurer.get_base_uri).to match(/^http:\/\//)
|
18
18
|
end
|
19
19
|
|
20
20
|
end
|
@@ -9,34 +9,34 @@ describe HttpStub::Controllers::StubActivatorController do
|
|
9
9
|
let(:stub_registry) { double("HttpStub::Models::StubRegistry").as_null_object }
|
10
10
|
let(:controller) { HttpStub::Controllers::StubActivatorController.new(stub_activator_registry, stub_registry) }
|
11
11
|
|
12
|
-
before(:
|
12
|
+
before(:example) { allow(JSON).to receive(:parse).and_return(stub_activator_options) }
|
13
13
|
|
14
14
|
describe "#register" do
|
15
15
|
|
16
|
-
before(:
|
17
|
-
HttpStub::Models::StubActivator.
|
16
|
+
before(:example) do
|
17
|
+
allow(HttpStub::Models::StubActivator).to receive(:new).and_return(stub_activator)
|
18
18
|
end
|
19
19
|
|
20
|
-
it "
|
21
|
-
JSON.
|
20
|
+
it "parses an options hash from the JSON request body" do
|
21
|
+
expect(JSON).to receive(:parse).with(request_body).and_return(stub_activator_options)
|
22
22
|
|
23
23
|
controller.register(request)
|
24
24
|
end
|
25
25
|
|
26
|
-
it "
|
27
|
-
HttpStub::Models::StubActivator.
|
26
|
+
it "creates a stub activator from the parsed options" do
|
27
|
+
expect(HttpStub::Models::StubActivator).to receive(:new).with(stub_activator_options).and_return(stub_activator)
|
28
28
|
|
29
29
|
controller.register(request)
|
30
30
|
end
|
31
31
|
|
32
|
-
it "
|
33
|
-
stub_activator_registry.
|
32
|
+
it "adds the created activator to the activator registry" do
|
33
|
+
expect(stub_activator_registry).to receive(:add).with(stub_activator, request)
|
34
34
|
|
35
35
|
controller.register(request)
|
36
36
|
end
|
37
37
|
|
38
|
-
it "
|
39
|
-
controller.register(request).
|
38
|
+
it "returns a success response" do
|
39
|
+
expect(controller.register(request)).to eql(HttpStub::Models::Response::SUCCESS)
|
40
40
|
end
|
41
41
|
|
42
42
|
end
|
@@ -45,36 +45,36 @@ describe HttpStub::Controllers::StubActivatorController do
|
|
45
45
|
|
46
46
|
describe "when a stub activator has been registered that is activated by the request" do
|
47
47
|
|
48
|
-
before(:
|
49
|
-
stub_activator_registry.
|
48
|
+
before(:example) do
|
49
|
+
allow(stub_activator_registry).to receive(:find_for).with(request).and_return(stub_activator)
|
50
50
|
end
|
51
51
|
|
52
|
-
it "
|
53
|
-
stub_registry.
|
52
|
+
it "adds the activators stub to the stub registry" do
|
53
|
+
expect(stub_registry).to receive(:add).with(the_stub, request)
|
54
54
|
|
55
55
|
controller.activate(request)
|
56
56
|
end
|
57
57
|
|
58
|
-
it "
|
59
|
-
controller.activate(request).
|
58
|
+
it "returns a success response" do
|
59
|
+
expect(controller.activate(request)).to eql(HttpStub::Models::Response::SUCCESS)
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
63
63
|
|
64
64
|
describe "when no stub activator is activated by the request" do
|
65
65
|
|
66
|
-
before(:
|
67
|
-
stub_activator_registry.
|
66
|
+
before(:example) do
|
67
|
+
allow(stub_activator_registry).to receive(:find_for).with(request).and_return(nil)
|
68
68
|
end
|
69
69
|
|
70
|
-
it "
|
71
|
-
stub_registry.
|
70
|
+
it "does not add a stub to the registry" do
|
71
|
+
expect(stub_registry).not_to receive(:add)
|
72
72
|
|
73
73
|
controller.activate(request)
|
74
74
|
end
|
75
75
|
|
76
|
-
it "
|
77
|
-
controller.activate(request).
|
76
|
+
it "returns an empty response" do
|
77
|
+
expect(controller.activate(request)).to eql(HttpStub::Models::Response::EMPTY)
|
78
78
|
end
|
79
79
|
|
80
80
|
end
|
@@ -83,8 +83,8 @@ describe HttpStub::Controllers::StubActivatorController do
|
|
83
83
|
|
84
84
|
describe "#clear" do
|
85
85
|
|
86
|
-
it "
|
87
|
-
stub_activator_registry.
|
86
|
+
it "clears the activator registry" do
|
87
|
+
expect(stub_activator_registry).to receive(:clear).with(request)
|
88
88
|
|
89
89
|
controller.clear(request)
|
90
90
|
end
|
@@ -8,34 +8,34 @@ describe HttpStub::Controllers::StubController do
|
|
8
8
|
let(:registry) { double(HttpStub::Models::Registry).as_null_object }
|
9
9
|
let(:controller) { HttpStub::Controllers::StubController.new(registry) }
|
10
10
|
|
11
|
-
before(:
|
11
|
+
before(:example) { allow(JSON).to receive(:parse).and_return(stub_options) }
|
12
12
|
|
13
13
|
describe "#register" do
|
14
14
|
|
15
|
-
before(:
|
16
|
-
HttpStub::Models::Stub.
|
15
|
+
before(:example) do
|
16
|
+
allow(HttpStub::Models::Stub).to receive(:new).and_return(the_stub)
|
17
17
|
end
|
18
18
|
|
19
|
-
it "
|
20
|
-
JSON.
|
19
|
+
it "parses an options hash from the JSON request body" do
|
20
|
+
expect(JSON).to receive(:parse).with(request_body).and_return(stub_options)
|
21
21
|
|
22
22
|
controller.register(request)
|
23
23
|
end
|
24
24
|
|
25
|
-
it "
|
26
|
-
HttpStub::Models::Stub.
|
25
|
+
it "creates a stub from the parsed options" do
|
26
|
+
expect(HttpStub::Models::Stub).to receive(:new).with(stub_options).and_return(the_stub)
|
27
27
|
|
28
28
|
controller.register(request)
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
32
|
-
registry.
|
31
|
+
it "adds the stub to the stub registry" do
|
32
|
+
expect(registry).to receive(:add).with(the_stub, request)
|
33
33
|
|
34
34
|
controller.register(request)
|
35
35
|
end
|
36
36
|
|
37
|
-
it "
|
38
|
-
controller.register(request).
|
37
|
+
it "returns a success response" do
|
38
|
+
expect(controller.register(request)).to eql(HttpStub::Models::Response::SUCCESS)
|
39
39
|
end
|
40
40
|
|
41
41
|
end
|
@@ -44,26 +44,26 @@ describe HttpStub::Controllers::StubController do
|
|
44
44
|
|
45
45
|
describe "when a stub has been registered that should be replayed for the request" do
|
46
46
|
|
47
|
-
before(:
|
48
|
-
registry.
|
47
|
+
before(:example) do
|
48
|
+
allow(registry).to receive(:find_for).with(request).and_return(the_stub)
|
49
49
|
end
|
50
50
|
|
51
|
-
it "
|
52
|
-
the_stub.
|
51
|
+
it "returns the stubs response" do
|
52
|
+
expect(the_stub).to receive(:response).and_return(response)
|
53
53
|
|
54
|
-
controller.replay(request).
|
54
|
+
expect(controller.replay(request)).to eql(response)
|
55
55
|
end
|
56
56
|
|
57
57
|
end
|
58
58
|
|
59
59
|
describe "when no stub should be replayed for the request" do
|
60
60
|
|
61
|
-
before(:
|
62
|
-
registry.
|
61
|
+
before(:example) do
|
62
|
+
allow(registry).to receive(:find_for).with(request).and_return(nil)
|
63
63
|
end
|
64
64
|
|
65
|
-
it "
|
66
|
-
controller.replay(request).
|
65
|
+
it "returns an empty response" do
|
66
|
+
expect(controller.replay(request)).to eql(HttpStub::Models::Response::EMPTY)
|
67
67
|
end
|
68
68
|
|
69
69
|
end
|
@@ -72,8 +72,8 @@ describe HttpStub::Controllers::StubController do
|
|
72
72
|
|
73
73
|
describe "#clear" do
|
74
74
|
|
75
|
-
it "
|
76
|
-
registry.
|
75
|
+
it "clears the stub registry" do
|
76
|
+
expect(registry).to receive(:clear).with(request)
|
77
77
|
|
78
78
|
controller.clear(request)
|
79
79
|
end
|
@@ -8,8 +8,8 @@ describe HttpStub::HashExtensions do
|
|
8
8
|
{ "lower" => 1, "UPPER" => 2, "MiXeDcAsE" => 3 }
|
9
9
|
end
|
10
10
|
|
11
|
-
it "
|
12
|
-
hash.downcase_and_underscore_keys.
|
11
|
+
it "downcases the string keys" do
|
12
|
+
expect(hash.downcase_and_underscore_keys).to eql({ "lower" => 1, "upper" => 2, "mixedcase" => 3 })
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "and keys contain underscores and hyphens" do
|
@@ -18,8 +18,8 @@ describe HttpStub::HashExtensions do
|
|
18
18
|
{ "has_underscore" => 1, "has-hypen" => 2, "has_underscore_and-hypen" => 3 }
|
19
19
|
end
|
20
20
|
|
21
|
-
it "
|
22
|
-
hash.downcase_and_underscore_keys.
|
21
|
+
it "downcases the string keys" do
|
22
|
+
expect(hash.downcase_and_underscore_keys).to eql({ "has_underscore" => 1,
|
23
23
|
"has_hypen" => 2,
|
24
24
|
"has_underscore_and_hypen" => 3 })
|
25
25
|
end
|
@@ -34,8 +34,8 @@ describe HttpStub::HashExtensions do
|
|
34
34
|
{ 1 => 2, :symbol => 3, nil => 4 }
|
35
35
|
end
|
36
36
|
|
37
|
-
it "
|
38
|
-
hash.downcase_and_underscore_keys.
|
37
|
+
it "does not alter a hash" do
|
38
|
+
expect(hash.downcase_and_underscore_keys).to eql({ 1 => 2, :symbol => 3, nil => 4 })
|
39
39
|
end
|
40
40
|
|
41
41
|
end
|
@@ -52,8 +52,8 @@ describe HttpStub::HashExtensions do
|
|
52
52
|
|
53
53
|
let(:hash) { hash_parameter }
|
54
54
|
|
55
|
-
it "
|
56
|
-
hash.has_hash?(hash_parameter).
|
55
|
+
it "returns true" do
|
56
|
+
expect(hash.has_hash?(hash_parameter)).to be(true)
|
57
57
|
end
|
58
58
|
|
59
59
|
end
|
@@ -62,8 +62,8 @@ describe HttpStub::HashExtensions do
|
|
62
62
|
|
63
63
|
let(:hash) { hash_parameter.merge("key4" => "value4") }
|
64
64
|
|
65
|
-
it "
|
66
|
-
hash.has_hash?(hash_parameter).
|
65
|
+
it "returns true" do
|
66
|
+
expect(hash.has_hash?(hash_parameter)).to be(true)
|
67
67
|
end
|
68
68
|
|
69
69
|
end
|
@@ -72,8 +72,8 @@ describe HttpStub::HashExtensions do
|
|
72
72
|
|
73
73
|
let(:hash) { { "key1" => "value1", "key2" => "nonMatchingValue", "key3" => "value3" } }
|
74
74
|
|
75
|
-
it "
|
76
|
-
hash.has_hash?(hash_parameter).
|
75
|
+
it "returns false" do
|
76
|
+
expect(hash.has_hash?(hash_parameter)).to be(false)
|
77
77
|
end
|
78
78
|
|
79
79
|
end
|
@@ -82,8 +82,8 @@ describe HttpStub::HashExtensions do
|
|
82
82
|
|
83
83
|
let(:hash) { { "key1" => "value1", "key3" => "value3" } }
|
84
84
|
|
85
|
-
it "
|
86
|
-
hash.has_hash?(hash_parameter).
|
85
|
+
it "returns false" do
|
86
|
+
expect(hash.has_hash?(hash_parameter)).to be(false)
|
87
87
|
end
|
88
88
|
|
89
89
|
end
|
@@ -92,8 +92,8 @@ describe HttpStub::HashExtensions do
|
|
92
92
|
|
93
93
|
let(:hash) { {} }
|
94
94
|
|
95
|
-
it "
|
96
|
-
hash.has_hash?(hash_parameter).
|
95
|
+
it "returns false" do
|
96
|
+
expect(hash.has_hash?(hash_parameter)).to be(false)
|
97
97
|
end
|
98
98
|
|
99
99
|
end
|
@@ -108,8 +108,8 @@ describe HttpStub::HashExtensions do
|
|
108
108
|
|
109
109
|
let(:hash) { {} }
|
110
110
|
|
111
|
-
it "
|
112
|
-
hash.has_hash?(hash_parameter).
|
111
|
+
it "returns true" do
|
112
|
+
expect(hash.has_hash?(hash_parameter)).to be(true)
|
113
113
|
end
|
114
114
|
|
115
115
|
end
|
@@ -118,8 +118,8 @@ describe HttpStub::HashExtensions do
|
|
118
118
|
|
119
119
|
let(:hash) { { "key" => "value" } }
|
120
120
|
|
121
|
-
it "
|
122
|
-
hash.has_hash?(hash_parameter).
|
121
|
+
it "returns true" do
|
122
|
+
expect(hash.has_hash?(hash_parameter)).to be(true)
|
123
123
|
end
|
124
124
|
|
125
125
|
end
|
@@ -134,8 +134,8 @@ describe HttpStub::HashExtensions do
|
|
134
134
|
|
135
135
|
let(:hash) { {} }
|
136
136
|
|
137
|
-
it "
|
138
|
-
hash.has_hash?(hash_parameter).
|
137
|
+
it "returns true" do
|
138
|
+
expect(hash.has_hash?(hash_parameter)).to be(true)
|
139
139
|
end
|
140
140
|
|
141
141
|
end
|
@@ -144,8 +144,8 @@ describe HttpStub::HashExtensions do
|
|
144
144
|
|
145
145
|
let(:hash) { { "key" => "value" } }
|
146
146
|
|
147
|
-
it "
|
148
|
-
hash.has_hash?(hash_parameter).
|
147
|
+
it "returns true" do
|
148
|
+
expect(hash.has_hash?(hash_parameter)).to be(true)
|
149
149
|
end
|
150
150
|
|
151
151
|
end
|
@@ -8,8 +8,8 @@ describe HttpStub::Models::ExactValueMatcher do
|
|
8
8
|
|
9
9
|
let(:actual_value) { stub_value }
|
10
10
|
|
11
|
-
it "
|
12
|
-
perform_match.
|
11
|
+
it "returns true" do
|
12
|
+
expect(perform_match).to be_truthy
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
@@ -18,8 +18,8 @@ describe HttpStub::Models::ExactValueMatcher do
|
|
18
18
|
|
19
19
|
let(:actual_value) { "not equal to stub value" }
|
20
20
|
|
21
|
-
it "
|
22
|
-
perform_match.
|
21
|
+
it "returns false" do
|
22
|
+
expect(perform_match).to be_falsey
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
@@ -13,22 +13,22 @@ describe HttpStub::Models::HashWithStringValueMatchers do
|
|
13
13
|
|
14
14
|
let(:value_matcher_hash) { HttpStub::Models::HashWithStringValueMatchers.new(stubbed_hash) }
|
15
15
|
|
16
|
-
before(:
|
17
|
-
value_matchers.each { |value| HttpStub::Models::StringValueMatcher.
|
16
|
+
before(:example) do
|
17
|
+
value_matchers.each { |value| allow(HttpStub::Models::StringValueMatcher).to receive(:new).with(value.to_s).and_return(value) }
|
18
18
|
end
|
19
19
|
|
20
|
-
it "
|
21
|
-
value_matcher_hash.
|
20
|
+
it "is a hash" do
|
21
|
+
expect(value_matcher_hash).to be_a(Hash)
|
22
22
|
end
|
23
23
|
|
24
24
|
describe "constructor" do
|
25
25
|
|
26
|
-
it "
|
26
|
+
it "creates a value matcher representation of each value in the hash" do
|
27
27
|
value_matchers.each do |value|
|
28
|
-
HttpStub::Models::StringValueMatcher.
|
28
|
+
expect(HttpStub::Models::StringValueMatcher).to receive(:new).with(value.to_s).and_return(value)
|
29
29
|
end
|
30
30
|
|
31
|
-
value_matcher_hash.values.
|
31
|
+
expect(value_matcher_hash.values).to eql(value_matchers)
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
@@ -50,27 +50,27 @@ describe HttpStub::Models::HashWithStringValueMatchers do
|
|
50
50
|
|
51
51
|
context "and the values match" do
|
52
52
|
|
53
|
-
before(:
|
54
|
-
value_matchers.each { |value| value.
|
53
|
+
before(:example) do
|
54
|
+
value_matchers.each { |value| allow(value).to receive(:match?).with("another #{value}").and_return(true) }
|
55
55
|
end
|
56
56
|
|
57
|
-
it "
|
58
|
-
value_matcher_hash.match?(provided_hash).
|
57
|
+
it "returns true" do
|
58
|
+
expect(value_matcher_hash.match?(provided_hash)).to be_truthy
|
59
59
|
end
|
60
60
|
|
61
61
|
end
|
62
62
|
|
63
63
|
context "and a value does not match" do
|
64
64
|
|
65
|
-
before(:
|
66
|
-
value_matchers.each { |value| value.
|
65
|
+
before(:example) do
|
66
|
+
value_matchers.each { |value| allow(value).to receive(:match?).with("another #{value}").and_return(true) }
|
67
67
|
|
68
68
|
non_matching_value = value_matchers[1]
|
69
|
-
non_matching_value.
|
69
|
+
allow(non_matching_value).to receive(:match?).with("another #{non_matching_value}").and_return(false)
|
70
70
|
end
|
71
71
|
|
72
|
-
it "
|
73
|
-
value_matcher_hash.match?(provided_hash).
|
72
|
+
it "returns false" do
|
73
|
+
expect(value_matcher_hash.match?(provided_hash)).to be_falsey
|
74
74
|
end
|
75
75
|
|
76
76
|
end
|
@@ -81,19 +81,19 @@ describe HttpStub::Models::HashWithStringValueMatchers do
|
|
81
81
|
|
82
82
|
let(:provided_hash) { { "key1" => "value1", "differentkey2" => "another value2", "key3" => "value3" } }
|
83
83
|
|
84
|
-
it "
|
84
|
+
it "determines if the corresponding value matches nil" do
|
85
85
|
expected_values = [ "value1", nil, "value3" ]
|
86
86
|
value_matchers.zip(expected_values).each do |value_matcher, expected_value|
|
87
|
-
value_matcher.
|
87
|
+
allow(value_matcher).to receive(:match?).with(expected_value)
|
88
88
|
end
|
89
89
|
|
90
90
|
value_matcher_hash.match?(provided_hash)
|
91
91
|
end
|
92
92
|
|
93
|
-
it "
|
94
|
-
value_matchers.each { |value| value.
|
93
|
+
it "returns the result of evaluating the value matchers" do
|
94
|
+
value_matchers.each { |value| allow(value).to receive(:match?).and_return(true) }
|
95
95
|
|
96
|
-
value_matcher_hash.match?(provided_hash).
|
96
|
+
expect(value_matcher_hash.match?(provided_hash)).to be_truthy
|
97
97
|
end
|
98
98
|
|
99
99
|
end
|
@@ -111,12 +111,12 @@ describe HttpStub::Models::HashWithStringValueMatchers do
|
|
111
111
|
|
112
112
|
context "and it has matching keys and values" do
|
113
113
|
|
114
|
-
before(:
|
115
|
-
value_matchers.each { |value| value.
|
114
|
+
before(:example) do
|
115
|
+
value_matchers.each { |value| allow(value).to receive(:match?).with("another #{value}").and_return(true) }
|
116
116
|
end
|
117
117
|
|
118
|
-
it "
|
119
|
-
value_matcher_hash.match?(provided_hash).
|
118
|
+
it "returns true" do
|
119
|
+
expect(value_matcher_hash.match?(provided_hash)).to be_truthy
|
120
120
|
end
|
121
121
|
|
122
122
|
end
|
@@ -133,8 +133,8 @@ describe HttpStub::Models::HashWithStringValueMatchers do
|
|
133
133
|
|
134
134
|
let(:provided_hash) { { "key" => "value" } }
|
135
135
|
|
136
|
-
it "
|
137
|
-
value_matcher_hash.match?(provided_hash).
|
136
|
+
it "returns true" do
|
137
|
+
expect(value_matcher_hash.match?(provided_hash)).to be_truthy
|
138
138
|
end
|
139
139
|
|
140
140
|
end
|
@@ -143,8 +143,8 @@ describe HttpStub::Models::HashWithStringValueMatchers do
|
|
143
143
|
|
144
144
|
let(:provided_hash) { {} }
|
145
145
|
|
146
|
-
it "
|
147
|
-
value_matcher_hash.match?(provided_hash).
|
146
|
+
it "returns true" do
|
147
|
+
expect(value_matcher_hash.match?(provided_hash)).to be_truthy
|
148
148
|
end
|
149
149
|
|
150
150
|
end
|