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
@@ -4,8 +4,8 @@ describe HttpStub::Models::Headers do
|
|
4
4
|
|
5
5
|
let(:headers) { HttpStub::Models::Headers.new(header_hash) }
|
6
6
|
|
7
|
-
it "
|
8
|
-
headers.
|
7
|
+
it "is a Hash" do
|
8
|
+
expect(headers).to be_a(Hash)
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "#to_s" do
|
@@ -14,14 +14,14 @@ describe HttpStub::Models::Headers do
|
|
14
14
|
|
15
15
|
let(:header_hash) { { "key1" => "value1", "key2" => "value2", "key3" => "value3" } }
|
16
16
|
|
17
|
-
it "
|
17
|
+
it "returns a string containing each header formatted as a conventional request header" do
|
18
18
|
result = headers.to_s
|
19
19
|
|
20
|
-
header_hash.each { |key, value| result.
|
20
|
+
header_hash.each { |key, value| expect(result).to match(/#{key}:#{value}/) }
|
21
21
|
end
|
22
22
|
|
23
|
-
it "
|
24
|
-
headers.to_s.
|
23
|
+
it "comma delimits the headers" do
|
24
|
+
expect(headers.to_s).to match(/key\d.value\d\, key\d.value\d\, key\d.value\d/)
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
@@ -30,8 +30,8 @@ describe HttpStub::Models::Headers do
|
|
30
30
|
|
31
31
|
let(:header_hash) { {} }
|
32
32
|
|
33
|
-
it "
|
34
|
-
headers.to_s.
|
33
|
+
it "returns an empty string" do
|
34
|
+
expect(headers.to_s).to eql("")
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
@@ -40,8 +40,8 @@ describe HttpStub::Models::Headers do
|
|
40
40
|
|
41
41
|
let(:header_hash) { nil }
|
42
42
|
|
43
|
-
it "
|
44
|
-
headers.to_s.
|
43
|
+
it "returns an empty string" do
|
44
|
+
expect(headers.to_s).to eql("")
|
45
45
|
end
|
46
46
|
|
47
47
|
end
|
@@ -10,8 +10,8 @@ describe HttpStub::Models::OmittedValueMatcher do
|
|
10
10
|
|
11
11
|
let(:actual_value) { nil }
|
12
12
|
|
13
|
-
it "
|
14
|
-
perform_match.
|
13
|
+
it "returns true" do
|
14
|
+
expect(perform_match).to be_truthy
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
@@ -20,8 +20,8 @@ describe HttpStub::Models::OmittedValueMatcher do
|
|
20
20
|
|
21
21
|
let(:actual_value) { "some non-empty string" }
|
22
22
|
|
23
|
-
it "
|
24
|
-
perform_match.
|
23
|
+
it "returns false" do
|
24
|
+
expect(perform_match).to be_falsey
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
@@ -30,8 +30,8 @@ describe HttpStub::Models::OmittedValueMatcher do
|
|
30
30
|
|
31
31
|
let(:actual_value) { "" }
|
32
32
|
|
33
|
-
it "
|
34
|
-
perform_match.
|
33
|
+
it "returns false" do
|
34
|
+
expect(perform_match).to be_falsey
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
@@ -43,8 +43,8 @@ describe HttpStub::Models::OmittedValueMatcher do
|
|
43
43
|
let(:stub_value) { "some other stub value" }
|
44
44
|
let(:actual_value) { nil }
|
45
45
|
|
46
|
-
it "
|
47
|
-
perform_match.
|
46
|
+
it "returns false" do
|
47
|
+
expect(perform_match).to be_falsey
|
48
48
|
end
|
49
49
|
|
50
50
|
end
|
@@ -10,8 +10,8 @@ describe HttpStub::Models::RegexpValueMatcher do
|
|
10
10
|
|
11
11
|
let(:actual_value) { "a789$z" }
|
12
12
|
|
13
|
-
it "
|
14
|
-
perform_match.
|
13
|
+
it "returns true" do
|
14
|
+
expect(perform_match).to be_truthy
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
@@ -20,8 +20,8 @@ describe HttpStub::Models::RegexpValueMatcher do
|
|
20
20
|
|
21
21
|
let(:actual_value) { "a789" }
|
22
22
|
|
23
|
-
it "
|
24
|
-
perform_match.
|
23
|
+
it "returns false" do
|
24
|
+
expect(perform_match).to be_falsey
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
@@ -33,8 +33,8 @@ describe HttpStub::Models::RegexpValueMatcher do
|
|
33
33
|
let(:stub_value) { "does not start with regexp:" }
|
34
34
|
let(:actual_value) { "some actual value" }
|
35
35
|
|
36
|
-
it "
|
37
|
-
perform_match.
|
36
|
+
it "returns false" do
|
37
|
+
expect(perform_match).to be_falsey
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
describe HttpStub::Models::Registry do
|
2
2
|
|
3
|
-
let(:
|
4
|
-
|
5
|
-
let(:logger) { double("Logger").as_null_object }
|
3
|
+
let(:logger) { double("Logger").as_null_object }
|
6
4
|
let(:request) { double("HttpRequest", logger: logger, inspect: "Request inspect result") }
|
7
5
|
|
6
|
+
let(:registry) { HttpStub::Models::Registry.new("a_model") }
|
7
|
+
|
8
8
|
describe "#add" do
|
9
9
|
|
10
|
-
it "
|
10
|
+
it "logs that the model has been registered" do
|
11
11
|
model = double("HttpStub::Models::Model", to_s: "Model as String")
|
12
|
-
logger.
|
12
|
+
expect(logger).to receive(:info).with(/Model as String/)
|
13
13
|
|
14
14
|
registry.add(model, request)
|
15
15
|
end
|
@@ -24,7 +24,7 @@ describe HttpStub::Models::Registry do
|
|
24
24
|
(1..3).map { |i| double("HttpStub::Models::Model#{i}", :satisfies? => false) }
|
25
25
|
end
|
26
26
|
|
27
|
-
before(:
|
27
|
+
before(:example) do
|
28
28
|
models.each { |model| registry.add(model, request) }
|
29
29
|
end
|
30
30
|
|
@@ -32,18 +32,18 @@ describe HttpStub::Models::Registry do
|
|
32
32
|
|
33
33
|
let(:matching_model) { models[1] }
|
34
34
|
|
35
|
-
before(:
|
35
|
+
before(:example) { allow(matching_model).to receive(:satisfies?).and_return(true) }
|
36
36
|
|
37
|
-
it "
|
38
|
-
registry.find_for(request).
|
37
|
+
it "returns the model" do
|
38
|
+
expect(registry.find_for(request)).to eql(matching_model)
|
39
39
|
end
|
40
40
|
|
41
41
|
describe "and the registry is subsequently cleared" do
|
42
42
|
|
43
|
-
before(:
|
43
|
+
before(:example) { registry.clear(request) }
|
44
44
|
|
45
|
-
it "
|
46
|
-
registry.find_for(request).
|
45
|
+
it "returns nil" do
|
46
|
+
expect(registry.find_for(request)).to be_nil
|
47
47
|
end
|
48
48
|
|
49
49
|
end
|
@@ -52,20 +52,20 @@ describe HttpStub::Models::Registry do
|
|
52
52
|
|
53
53
|
describe "and multiple registered models satisfy the request" do
|
54
54
|
|
55
|
-
before(:
|
56
|
-
[0, 2].each { |i| models[i].
|
55
|
+
before(:example) do
|
56
|
+
[0, 2].each { |i| allow(models[i]).to receive(:satisfies?).and_return(true) }
|
57
57
|
end
|
58
58
|
|
59
|
-
it "
|
60
|
-
registry.find_for(request).
|
59
|
+
it "supports model overrides by returning the last model registered" do
|
60
|
+
expect(registry.find_for(request)).to eql(models[2])
|
61
61
|
end
|
62
62
|
|
63
63
|
end
|
64
64
|
|
65
65
|
describe "and no registered models match the request" do
|
66
66
|
|
67
|
-
it "
|
68
|
-
registry.find_for(request).
|
67
|
+
it "returns nil" do
|
68
|
+
expect(registry.find_for(request)).to be_nil
|
69
69
|
end
|
70
70
|
|
71
71
|
end
|
@@ -74,14 +74,14 @@ describe HttpStub::Models::Registry do
|
|
74
74
|
|
75
75
|
describe "when no model has been registered" do
|
76
76
|
|
77
|
-
it "
|
78
|
-
registry.find_for(request).
|
77
|
+
it "returns nil" do
|
78
|
+
expect(registry.find_for(request)).to be_nil
|
79
79
|
end
|
80
80
|
|
81
81
|
end
|
82
82
|
|
83
83
|
it "it should log model discovery diagnostics that includes the complete details of the request" do
|
84
|
-
logger.
|
84
|
+
expect(logger).to receive(:info).with(/Request inspect result/)
|
85
85
|
|
86
86
|
registry.find_for(request)
|
87
87
|
end
|
@@ -96,30 +96,73 @@ describe HttpStub::Models::Registry do
|
|
96
96
|
(1..3).map { |i| double("HttpStub::Models::Model#{i}", :satisfies? => false) }
|
97
97
|
end
|
98
98
|
|
99
|
-
before(:
|
99
|
+
before(:example) do
|
100
100
|
models.each { |model| registry.add(model, request) }
|
101
101
|
end
|
102
102
|
|
103
|
-
it "
|
104
|
-
registry.all.
|
103
|
+
it "returns the registered models in the order they were added" do
|
104
|
+
expect(registry.all).to eql(models.reverse)
|
105
105
|
end
|
106
106
|
|
107
107
|
end
|
108
108
|
|
109
109
|
describe "when no model has been registered" do
|
110
110
|
|
111
|
-
it "
|
112
|
-
registry.all.
|
111
|
+
it "returns an empty list" do
|
112
|
+
expect(registry.all).to eql([])
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "#copy" do
|
120
|
+
|
121
|
+
class HttpStub::Models::CopyableModel
|
122
|
+
|
123
|
+
attr_reader :name
|
124
|
+
|
125
|
+
def initialize(name)
|
126
|
+
@name = name
|
127
|
+
end
|
128
|
+
|
129
|
+
def eql?(other)
|
130
|
+
@name = other.name
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
subject { registry.copy }
|
136
|
+
|
137
|
+
context "when multiple models have been registered" do
|
138
|
+
|
139
|
+
let(:models) { (1..3).map { |i| HttpStub::Models::CopyableModel.new("model_#{i}") } }
|
140
|
+
|
141
|
+
before(:each) { models.each { |model| registry.add(model, request) } }
|
142
|
+
|
143
|
+
it "returns a registry containing the models" do
|
144
|
+
result = subject
|
145
|
+
|
146
|
+
expect(result.all).to eql(models)
|
113
147
|
end
|
114
148
|
|
115
149
|
end
|
116
150
|
|
151
|
+
it "returns a registry that changes independently of the copied registry" do
|
152
|
+
model_to_add = HttpStub::Models::CopyableModel.new("model_to_add")
|
153
|
+
|
154
|
+
result = subject
|
155
|
+
|
156
|
+
registry.add(model_to_add, request)
|
157
|
+
expect(result.all).not_to include(model_to_add)
|
158
|
+
end
|
159
|
+
|
117
160
|
end
|
118
161
|
|
119
162
|
describe "#clear" do
|
120
163
|
|
121
|
-
it "
|
122
|
-
logger.
|
164
|
+
it "logs that the models are being cleared" do
|
165
|
+
expect(logger).to receive(:info).with(/clearing a_model/i)
|
123
166
|
|
124
167
|
registry.clear(request)
|
125
168
|
end
|
@@ -18,8 +18,8 @@ describe HttpStub::Models::RequestHeaderParser do
|
|
18
18
|
|
19
19
|
let(:http_env_elements) { { "HTTP_KEY1" => "value1", "HTTP_KEY2" => "value2", "HTTP_KEY3" => "value3" } }
|
20
20
|
|
21
|
-
it "
|
22
|
-
HttpStub::Models::RequestHeaderParser.parse(request).
|
21
|
+
it "returns a hash containing only those entries with the prefix removed" do
|
22
|
+
expect(HttpStub::Models::RequestHeaderParser.parse(request)).to eql({ "KEY1" => "value1",
|
23
23
|
"KEY2" => "value2",
|
24
24
|
"KEY3" => "value3" })
|
25
25
|
end
|
@@ -30,8 +30,8 @@ describe HttpStub::Models::RequestHeaderParser do
|
|
30
30
|
|
31
31
|
let(:http_env_elements) { {} }
|
32
32
|
|
33
|
-
it "
|
34
|
-
HttpStub::Models::RequestHeaderParser.parse(request).
|
33
|
+
it "returns an empty hash" do
|
34
|
+
expect(HttpStub::Models::RequestHeaderParser.parse(request)).to eql({})
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
@@ -6,8 +6,8 @@ describe HttpStub::Models::RequestPipeline do
|
|
6
6
|
|
7
7
|
let(:response) { double(HttpStub::Models::Response, delay_in_seconds: 5) }
|
8
8
|
|
9
|
-
it "
|
10
|
-
request_pipeline.
|
9
|
+
it "sleeps for specified duration" do
|
10
|
+
expect(request_pipeline).to receive(:sleep).with(5)
|
11
11
|
|
12
12
|
request_pipeline.before_halt(response)
|
13
13
|
end
|
@@ -15,12 +15,12 @@ describe HttpStub::Models::Response do
|
|
15
15
|
|
16
16
|
let(:response) { HttpStub::Models::Response::SUCCESS }
|
17
17
|
|
18
|
-
it "
|
19
|
-
response.status.
|
18
|
+
it "has a status of 200" do
|
19
|
+
expect(response.status).to eql(200)
|
20
20
|
end
|
21
21
|
|
22
|
-
it "
|
23
|
-
response.body.
|
22
|
+
it "has a body containing OK to visually indicate success to those interacting via a browser" do
|
23
|
+
expect(response.body).to match(/OK/)
|
24
24
|
end
|
25
25
|
|
26
26
|
end
|
@@ -29,12 +29,12 @@ describe HttpStub::Models::Response do
|
|
29
29
|
|
30
30
|
let(:response) { HttpStub::Models::Response::ERROR }
|
31
31
|
|
32
|
-
it "
|
33
|
-
response.status.
|
32
|
+
it "has a status of 404" do
|
33
|
+
expect(response.status).to eql(404)
|
34
34
|
end
|
35
35
|
|
36
|
-
it "
|
37
|
-
response.body.
|
36
|
+
it "has a body containing ERROR to visually indicate the error to those interacting via a browser" do
|
37
|
+
expect(response.body).to match(/ERROR/)
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
@@ -45,8 +45,8 @@ describe HttpStub::Models::Response do
|
|
45
45
|
|
46
46
|
context "that is an integer" do
|
47
47
|
|
48
|
-
it "
|
49
|
-
response.status.
|
48
|
+
it "returns the value provided" do
|
49
|
+
expect(response.status).to eql(status)
|
50
50
|
end
|
51
51
|
|
52
52
|
end
|
@@ -55,8 +55,8 @@ describe HttpStub::Models::Response do
|
|
55
55
|
|
56
56
|
let(:status) { "" }
|
57
57
|
|
58
|
-
it "
|
59
|
-
response.status.
|
58
|
+
it "returns 200" do
|
59
|
+
expect(response.status).to eql(200)
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
@@ -67,8 +67,8 @@ describe HttpStub::Models::Response do
|
|
67
67
|
|
68
68
|
let(:response) { HttpStub::Models::Response.new("body" => body, "delay_in_seconds" => delay_in_seconds) }
|
69
69
|
|
70
|
-
it "
|
71
|
-
response.status.
|
70
|
+
it "returns 200" do
|
71
|
+
expect(response.status).to eql(200)
|
72
72
|
end
|
73
73
|
|
74
74
|
end
|
@@ -77,8 +77,8 @@ describe HttpStub::Models::Response do
|
|
77
77
|
|
78
78
|
describe "#body" do
|
79
79
|
|
80
|
-
it "
|
81
|
-
response.body.
|
80
|
+
it "returns the value provided in the arguments" do
|
81
|
+
expect(response.body).to eql("A response body")
|
82
82
|
end
|
83
83
|
|
84
84
|
end
|
@@ -89,8 +89,8 @@ describe HttpStub::Models::Response do
|
|
89
89
|
|
90
90
|
context "that is an integer" do
|
91
91
|
|
92
|
-
it "
|
93
|
-
response.delay_in_seconds.
|
92
|
+
it "returns the value" do
|
93
|
+
expect(response.delay_in_seconds).to eql(delay_in_seconds)
|
94
94
|
end
|
95
95
|
|
96
96
|
end
|
@@ -99,8 +99,8 @@ describe HttpStub::Models::Response do
|
|
99
99
|
|
100
100
|
let(:delay_in_seconds) { "" }
|
101
101
|
|
102
|
-
it "
|
103
|
-
response.delay_in_seconds.
|
102
|
+
it "returns 0" do
|
103
|
+
expect(response.delay_in_seconds).to eql(0)
|
104
104
|
end
|
105
105
|
|
106
106
|
end
|
@@ -111,8 +111,8 @@ describe HttpStub::Models::Response do
|
|
111
111
|
|
112
112
|
let(:response) { HttpStub::Models::Response.new("status" => status, "body" => body) }
|
113
113
|
|
114
|
-
it "
|
115
|
-
response.delay_in_seconds.
|
114
|
+
it "returns 0" do
|
115
|
+
expect(response.delay_in_seconds).to eql(0)
|
116
116
|
end
|
117
117
|
|
118
118
|
end
|
@@ -123,8 +123,8 @@ describe HttpStub::Models::Response do
|
|
123
123
|
|
124
124
|
let(:response_header_hash) { response.headers.to_hash }
|
125
125
|
|
126
|
-
it "
|
127
|
-
response.headers.
|
126
|
+
it "is Headers" do
|
127
|
+
expect(response.headers).to be_a(HttpStub::Models::Headers)
|
128
128
|
end
|
129
129
|
|
130
130
|
context "when headers are provided" do
|
@@ -135,8 +135,8 @@ describe HttpStub::Models::Response do
|
|
135
135
|
{ "content-type" => "some/content/type", "some_header" => "some value", "another_header" => "another value" }
|
136
136
|
end
|
137
137
|
|
138
|
-
it "
|
139
|
-
response_header_hash.
|
138
|
+
it "returns headers including the provided headers" do
|
139
|
+
expect(response_header_hash).to eql(headers)
|
140
140
|
end
|
141
141
|
|
142
142
|
end
|
@@ -151,12 +151,12 @@ describe HttpStub::Models::Response do
|
|
151
151
|
}
|
152
152
|
end
|
153
153
|
|
154
|
-
it "
|
155
|
-
response_header_hash.
|
154
|
+
it "returns headers including the provided headers" do
|
155
|
+
expect(response_header_hash).to include(headers)
|
156
156
|
end
|
157
157
|
|
158
|
-
it "
|
159
|
-
response_header_hash.
|
158
|
+
it "returns headers including json as the default response content type" do
|
159
|
+
expect(response_header_hash).to include("content-type" => "application/json")
|
160
160
|
end
|
161
161
|
|
162
162
|
end
|
@@ -167,8 +167,8 @@ describe HttpStub::Models::Response do
|
|
167
167
|
|
168
168
|
let(:headers) { nil }
|
169
169
|
|
170
|
-
it "
|
171
|
-
response_header_hash.
|
170
|
+
it "returns headers containing json as the default response content type" do
|
171
|
+
expect(response_header_hash).to eql("content-type" => "application/json")
|
172
172
|
end
|
173
173
|
|
174
174
|
end
|
@@ -179,24 +179,24 @@ describe HttpStub::Models::Response do
|
|
179
179
|
|
180
180
|
context "when the response is EMPTY" do
|
181
181
|
|
182
|
-
it "
|
183
|
-
HttpStub::Models::Response::EMPTY.
|
182
|
+
it "returns true" do
|
183
|
+
expect(HttpStub::Models::Response::EMPTY).to be_empty
|
184
184
|
end
|
185
185
|
|
186
186
|
end
|
187
187
|
|
188
188
|
context "when the response is not EMPTY but contains no values" do
|
189
189
|
|
190
|
-
it "
|
191
|
-
HttpStub::Models::Response.new.
|
190
|
+
it "returns true" do
|
191
|
+
expect(HttpStub::Models::Response.new).to be_empty
|
192
192
|
end
|
193
193
|
|
194
194
|
end
|
195
195
|
|
196
196
|
context "when the response is not EMPTY" do
|
197
197
|
|
198
|
-
it "
|
199
|
-
HttpStub::Models::Response::SUCCESS.
|
198
|
+
it "returns false" do
|
199
|
+
expect(HttpStub::Models::Response::SUCCESS).not_to be_empty
|
200
200
|
end
|
201
201
|
|
202
202
|
end
|