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,25 +4,25 @@ describe HttpStub::Configurer::Request::ControllableValue do
|
|
4
4
|
|
5
5
|
let(:value) { "some value" }
|
6
6
|
|
7
|
-
it "
|
8
|
-
HttpStub::Configurer::Request::Regexpable.
|
7
|
+
it "formats the potential control value via the Regexpable formatter" do
|
8
|
+
expect(HttpStub::Configurer::Request::Regexpable).to receive(:format).with(value)
|
9
9
|
|
10
10
|
perform_format
|
11
11
|
end
|
12
12
|
|
13
|
-
it "
|
13
|
+
it "chains formatting by formatting the Regexpable formatter result via the Omittable formatter" do
|
14
14
|
regexp_formatted_value = "some regexp formatted value"
|
15
|
-
HttpStub::Configurer::Request::Regexpable.
|
16
|
-
HttpStub::Configurer::Request::Omittable.
|
15
|
+
allow(HttpStub::Configurer::Request::Regexpable).to receive(:format).and_return(regexp_formatted_value)
|
16
|
+
expect(HttpStub::Configurer::Request::Omittable).to receive(:format).with(regexp_formatted_value)
|
17
17
|
|
18
18
|
perform_format
|
19
19
|
end
|
20
20
|
|
21
|
-
it "
|
21
|
+
it "returns the Omittable formatter result" do
|
22
22
|
omit_formatted_value = "some omit formatted value"
|
23
|
-
HttpStub::Configurer::Request::Omittable.
|
23
|
+
allow(HttpStub::Configurer::Request::Omittable).to receive(:format).and_return(omit_formatted_value)
|
24
24
|
|
25
|
-
perform_format.
|
25
|
+
expect(perform_format).to eql(omit_formatted_value)
|
26
26
|
end
|
27
27
|
|
28
28
|
def perform_format
|
@@ -13,13 +13,13 @@ describe HttpStub::Configurer::Request::Omittable do
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
16
|
+
it "returns a hash containing the omitted values converted to 'control:omitted'" do
|
17
17
|
expected_hash = (1..5).reduce({}) do |result, i|
|
18
18
|
result["key#{i}"] = (i % 2 == 0) ? "value#{i}" : "control:omitted"
|
19
19
|
result
|
20
20
|
end
|
21
21
|
|
22
|
-
perform_format.
|
22
|
+
expect(perform_format).to eql(expected_hash)
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
@@ -33,8 +33,8 @@ describe HttpStub::Configurer::Request::Omittable do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
it "
|
37
|
-
perform_format.
|
36
|
+
it "returns the hash unchanged" do
|
37
|
+
expect(perform_format).to eql(value)
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
@@ -43,8 +43,8 @@ describe HttpStub::Configurer::Request::Omittable do
|
|
43
43
|
|
44
44
|
let(:value) { {} }
|
45
45
|
|
46
|
-
it "
|
47
|
-
perform_format.
|
46
|
+
it "returns the hash unchanged" do
|
47
|
+
expect(perform_format).to eql({})
|
48
48
|
end
|
49
49
|
|
50
50
|
end
|
@@ -55,8 +55,8 @@ describe HttpStub::Configurer::Request::Omittable do
|
|
55
55
|
|
56
56
|
let(:value) { "not a hash" }
|
57
57
|
|
58
|
-
it "
|
59
|
-
perform_format.
|
58
|
+
it "returns the value unchanged" do
|
59
|
+
expect(perform_format).to eql(value)
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
@@ -6,8 +6,8 @@ describe HttpStub::Configurer::Request::Regexpable do
|
|
6
6
|
|
7
7
|
let(:value) { "some string value" }
|
8
8
|
|
9
|
-
it "
|
10
|
-
HttpStub::Configurer::Request::Regexpable.format(value).
|
9
|
+
it "returns the value unaltered" do
|
10
|
+
expect(HttpStub::Configurer::Request::Regexpable.format(value)).to eql(value)
|
11
11
|
end
|
12
12
|
|
13
13
|
end
|
@@ -16,20 +16,20 @@ describe HttpStub::Configurer::Request::Regexpable do
|
|
16
16
|
|
17
17
|
let(:value) { /.+?[a-z]/ }
|
18
18
|
|
19
|
-
it "
|
20
|
-
HttpStub::Configurer::Request::Regexpable.format(value).
|
19
|
+
it "returns a string prefixed by 'regexp:'" do
|
20
|
+
expect(HttpStub::Configurer::Request::Regexpable.format(value)).to start_with("regexp:")
|
21
21
|
end
|
22
22
|
|
23
|
-
it "
|
24
|
-
HttpStub::Configurer::Request::Regexpable.format(value).
|
23
|
+
it "contains the regular expression converted to a string" do
|
24
|
+
expect(HttpStub::Configurer::Request::Regexpable.format(value)).to end_with(".+?[a-z]")
|
25
25
|
end
|
26
26
|
|
27
27
|
describe "and the regular expression contain escaped meta characters" do
|
28
28
|
|
29
29
|
let(:value) { /\^\+\[/ }
|
30
30
|
|
31
|
-
it "
|
32
|
-
HttpStub::Configurer::Request::Regexpable.format(value).
|
31
|
+
it "returns a string that retains the escape characters" do
|
32
|
+
expect(HttpStub::Configurer::Request::Regexpable.format(value)).to include("\\^\\+\\[")
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
@@ -38,8 +38,8 @@ describe HttpStub::Configurer::Request::Regexpable do
|
|
38
38
|
|
39
39
|
let(:value) { /\/some\/path/ }
|
40
40
|
|
41
|
-
it "
|
42
|
-
HttpStub::Configurer::Request::Regexpable.format(value).
|
41
|
+
it "represents the path separators as a single forward-slash" do
|
42
|
+
expect(HttpStub::Configurer::Request::Regexpable.format(value)).to end_with("/some/path")
|
43
43
|
end
|
44
44
|
|
45
45
|
end
|
@@ -52,10 +52,10 @@ describe HttpStub::Configurer::Request::Regexpable do
|
|
52
52
|
|
53
53
|
let(:value) { { key1: "value1", key2: /^.*value2$/, key3: "value3" } }
|
54
54
|
|
55
|
-
it "
|
55
|
+
it "returns a json representation of the hash whose values are their regexpable form" do
|
56
56
|
expected_formatted_hash = {key1: "value1", key2: "regexp:^.*value2$", key3: "value3"}
|
57
57
|
|
58
|
-
HttpStub::Configurer::Request::Regexpable.format(value).
|
58
|
+
expect(HttpStub::Configurer::Request::Regexpable.format(value)).to eql(expected_formatted_hash)
|
59
59
|
end
|
60
60
|
|
61
61
|
end
|
@@ -64,8 +64,8 @@ describe HttpStub::Configurer::Request::Regexpable do
|
|
64
64
|
|
65
65
|
let(:value) { {} }
|
66
66
|
|
67
|
-
it "
|
68
|
-
HttpStub::Configurer::Request::Regexpable.format(value).
|
67
|
+
it "returns an empty hash" do
|
68
|
+
expect(HttpStub::Configurer::Request::Regexpable.format(value)).to eql({})
|
69
69
|
end
|
70
70
|
|
71
71
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
describe HttpStub::Configurer::Request::StubActivatorPayloadBuilder do
|
2
|
+
|
3
|
+
include_context "stub payload builder arguments"
|
4
|
+
|
5
|
+
let(:stub_payload) { { "stub_payload_key" => "stub payload value" } }
|
6
|
+
let(:stub_builder) { instance_double(HttpStub::Configurer::Request::StubPayloadBuilder, build: stub_payload) }
|
7
|
+
|
8
|
+
let(:builder) { HttpStub::Configurer::Request::StubActivatorPayloadBuilder.new }
|
9
|
+
|
10
|
+
before(:example) do
|
11
|
+
allow(HttpStub::Configurer::Request::StubPayloadBuilder).to receive(:new).and_return(stub_builder)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#match_request" do
|
15
|
+
|
16
|
+
it "delegates to a stub payload builder" do
|
17
|
+
expect(stub_builder).to receive(:match_request).with(uri, request_options)
|
18
|
+
|
19
|
+
builder.match_request(uri, request_options)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#with_response" do
|
25
|
+
|
26
|
+
it "delegates to a stub payload builder" do
|
27
|
+
expect(stub_builder).to receive(:with_response).with(response_options)
|
28
|
+
|
29
|
+
builder.with_response(response_options)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#and_add_stub" do
|
35
|
+
|
36
|
+
let(:trigger_builder) { instance_double(HttpStub::Configurer::Request::StubPayloadBuilder) }
|
37
|
+
|
38
|
+
it "delegates to a stub payload builder" do
|
39
|
+
expect(stub_builder).to receive(:and_add_stub).with(trigger_builder)
|
40
|
+
|
41
|
+
builder.and_add_stub(trigger_builder)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#build" do
|
47
|
+
|
48
|
+
subject { builder.build }
|
49
|
+
|
50
|
+
context "when a path is established" do
|
51
|
+
|
52
|
+
let(:activation_uri) { "http://some/activation/uri" }
|
53
|
+
|
54
|
+
before(:example) { builder.path(activation_uri) }
|
55
|
+
|
56
|
+
it "returns a payload that includes the activation uri" do
|
57
|
+
expect(subject).to include(activation_uri: activation_uri)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "builds a stub payload" do
|
61
|
+
expect(stub_builder).to receive(:build)
|
62
|
+
|
63
|
+
subject
|
64
|
+
end
|
65
|
+
|
66
|
+
it "returns a payload that includes the stub payload" do
|
67
|
+
expect(subject).to include(stub_payload)
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -2,47 +2,40 @@ describe HttpStub::Configurer::Request::StubActivator do
|
|
2
2
|
|
3
3
|
describe "#initialize" do
|
4
4
|
|
5
|
-
|
6
|
-
let(:stub_request_content_type) { "Some content type" }
|
7
|
-
let(:stub_request) { double("StubRequest", :content_type => stub_request_content_type, :body => stub_request_body) }
|
5
|
+
context "when provided a payload" do
|
8
6
|
|
9
|
-
|
7
|
+
let(:payload) { { payload_key: "payload value" } }
|
10
8
|
|
11
|
-
|
9
|
+
let(:request) { HttpStub::Configurer::Request::StubActivator.new(payload) }
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
let(:request) { HttpStub::Configurer::Request::StubActivator.new(activation_uri, stub_uri, stub_options) }
|
18
|
-
let(:request_body) { JSON.parse(request.body) }
|
11
|
+
it "creates a HTTP POST request" do
|
12
|
+
expect(request.method).to eql("POST")
|
13
|
+
end
|
19
14
|
|
20
|
-
it "
|
21
|
-
request.
|
15
|
+
it "submits the request to '/stubs/activators'" do
|
16
|
+
expect(request.path).to eql("/stubs/activators")
|
22
17
|
end
|
23
18
|
|
24
|
-
it "
|
25
|
-
request.
|
19
|
+
it "sets the content type to json" do
|
20
|
+
expect(request.content_type).to eql("application/json")
|
26
21
|
end
|
27
22
|
|
28
|
-
it "
|
29
|
-
request.
|
23
|
+
it "sets the body to the JSON representation of the provided payload" do
|
24
|
+
expect(request.body).to eql(payload.to_json)
|
30
25
|
end
|
31
26
|
|
32
|
-
|
27
|
+
end
|
33
28
|
|
34
|
-
|
35
|
-
HttpStub::Configurer::Request::Stub.should_receive(:new).with(stub_uri, stub_options).and_return(stub_request)
|
29
|
+
end
|
36
30
|
|
37
|
-
|
38
|
-
end
|
31
|
+
describe "#activation_uri" do
|
39
32
|
|
40
|
-
|
41
|
-
request_body.should include({ "activation_uri" => activation_uri })
|
42
|
-
end
|
33
|
+
let(:activation_uri) { "http://some/activation/uri" }
|
43
34
|
|
44
|
-
|
35
|
+
let(:request) { HttpStub::Configurer::Request::StubActivator.new(activation_uri: activation_uri) }
|
45
36
|
|
37
|
+
it "should return the activation uri from the payload" do
|
38
|
+
expect(request.activation_uri).to eql(activation_uri)
|
46
39
|
end
|
47
40
|
|
48
41
|
end
|
@@ -0,0 +1,203 @@
|
|
1
|
+
describe HttpStub::Configurer::Request::StubPayloadBuilder do
|
2
|
+
|
3
|
+
let(:builder) { HttpStub::Configurer::Request::StubPayloadBuilder.new }
|
4
|
+
|
5
|
+
shared_context "add stub triggers" do
|
6
|
+
|
7
|
+
let(:trigger_payloads) { (1..3).map { |i| { "trigger_#{i}_key" => "trigger #{i} value" } } }
|
8
|
+
let(:trigger_builders) do
|
9
|
+
trigger_payloads.map do |payload|
|
10
|
+
instance_double(HttpStub::Configurer::Request::StubPayloadBuilder, build: payload)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
before(:example) { trigger_builders.each { |trigger_builder| builder.and_add_stub(trigger_builder) } }
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#build" do
|
19
|
+
|
20
|
+
context "when provided a uri and stub arguments" do
|
21
|
+
|
22
|
+
include_context "stub payload builder arguments"
|
23
|
+
|
24
|
+
subject { builder.build }
|
25
|
+
|
26
|
+
before(:example) do
|
27
|
+
allow(HttpStub::Configurer::Request::ControllableValue).to receive(:format)
|
28
|
+
|
29
|
+
builder.match_request(uri, request_options)
|
30
|
+
builder.with_response(response_options)
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when request header is provided" do
|
34
|
+
|
35
|
+
it "formats the headers into control values" do
|
36
|
+
expect(HttpStub::Configurer::Request::ControllableValue).to receive(:format).with(request_headers)
|
37
|
+
|
38
|
+
subject
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
context "when no request header is provided" do
|
44
|
+
|
45
|
+
let(:request_headers) { nil }
|
46
|
+
|
47
|
+
it "formats an empty header hash" do
|
48
|
+
expect(HttpStub::Configurer::Request::ControllableValue).to receive(:format).with({})
|
49
|
+
|
50
|
+
subject
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when a request parameter is provided" do
|
56
|
+
|
57
|
+
it "formats the request parameters into control values" do
|
58
|
+
expect(HttpStub::Configurer::Request::ControllableValue).to receive(:format).with(request_parameters)
|
59
|
+
|
60
|
+
subject
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
context "when no request parameter is provided" do
|
66
|
+
|
67
|
+
let(:request_parameters) { nil }
|
68
|
+
|
69
|
+
it "formats an empty parameter hash" do
|
70
|
+
expect(HttpStub::Configurer::Request::ControllableValue).to receive(:format).with({})
|
71
|
+
|
72
|
+
subject
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
context "when stub triggers are added" do
|
78
|
+
|
79
|
+
include_context "add stub triggers"
|
80
|
+
|
81
|
+
it "builds the payload for each trigger" do
|
82
|
+
trigger_builders.each { |trigger_builder| expect(trigger_builder).to receive(:build) }
|
83
|
+
|
84
|
+
subject
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
context "builds a request payload" do
|
90
|
+
|
91
|
+
it "has an entry containing the control value representation of the uri" do
|
92
|
+
allow(HttpStub::Configurer::Request::ControllableValue).to(
|
93
|
+
receive(:format).with(uri).and_return("uri as a string")
|
94
|
+
)
|
95
|
+
|
96
|
+
expect(subject).to include(uri: "uri as a string")
|
97
|
+
end
|
98
|
+
|
99
|
+
it "has an entry for the method option" do
|
100
|
+
expect(subject).to include(method: stub_method)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "has an entry containing the string representation of the request headers" do
|
104
|
+
allow(HttpStub::Configurer::Request::ControllableValue).to(
|
105
|
+
receive(:format).with(request_headers).and_return("request headers as string")
|
106
|
+
)
|
107
|
+
|
108
|
+
expect(subject).to include(headers: "request headers as string")
|
109
|
+
end
|
110
|
+
|
111
|
+
it "has an entry containing the string representation of the request parameters" do
|
112
|
+
allow(HttpStub::Configurer::Request::ControllableValue).to(
|
113
|
+
receive(:format).with(request_parameters).and_return("request parameters as string")
|
114
|
+
)
|
115
|
+
|
116
|
+
expect(subject).to include(parameters: "request parameters as string")
|
117
|
+
end
|
118
|
+
|
119
|
+
context "when a status response argument is provided" do
|
120
|
+
|
121
|
+
it "has a response entry for the argument" do
|
122
|
+
expect(subject[:response]).to include(status: response_status)
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
context "when no status response argument is provided" do
|
128
|
+
|
129
|
+
let(:response_status) { nil }
|
130
|
+
|
131
|
+
it "has a response entry with an empty status code" do
|
132
|
+
expect(subject[:response]).to include(status: "")
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
context "when response headers are provided" do
|
138
|
+
|
139
|
+
let(:response_headers) { { response_header_name: "value" } }
|
140
|
+
|
141
|
+
it "has a headers response entry containing the the provided headers" do
|
142
|
+
expect(subject[:response]).to include(headers: response_headers)
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
context "when response headers are omitted" do
|
148
|
+
|
149
|
+
let (:response_headers) { nil }
|
150
|
+
|
151
|
+
it "has a headers response entry containing an empty hash" do
|
152
|
+
expect(subject[:response]).to include(headers: {})
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
it "has an entry for the response body argument" do
|
158
|
+
expect(subject[:response]).to include(body: response_body)
|
159
|
+
end
|
160
|
+
|
161
|
+
context "when a delay option is provided" do
|
162
|
+
|
163
|
+
it "has a response entry for the argument" do
|
164
|
+
expect(subject[:response]).to include(delay_in_seconds: response_delay_in_seconds)
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
context "when a delay option is omitted" do
|
170
|
+
|
171
|
+
let(:response_delay_in_seconds) { nil }
|
172
|
+
|
173
|
+
it "has a response entry with an empty delay" do
|
174
|
+
expect(subject[:response]).to include(delay_in_seconds: "")
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
|
179
|
+
context "when stub triggers are added" do
|
180
|
+
|
181
|
+
include_context "add stub triggers"
|
182
|
+
|
183
|
+
it "has a triggers entry containing the stub trigger payloads" do
|
184
|
+
expect(subject).to include(triggers: trigger_payloads)
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
context "when no stub triggers are added" do
|
190
|
+
|
191
|
+
it "has a triggers entry containing an empty hash" do
|
192
|
+
expect(subject).to include(triggers: [])
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
200
|
+
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|