http_stub 0.27.0 → 0.28.0.beta1
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/client.rb +18 -0
- data/lib/http_stub/client/client.rb +28 -0
- data/lib/http_stub/client/request.rb +38 -0
- data/lib/http_stub/client/server.rb +20 -0
- data/lib/http_stub/client/session.rb +43 -0
- data/lib/http_stub/configurator.rb +61 -0
- data/lib/http_stub/configurator/endpoint_template.rb +24 -0
- data/lib/http_stub/configurator/part.rb +23 -0
- data/lib/http_stub/configurator/scenario.rb +42 -0
- data/lib/http_stub/configurator/server.rb +53 -0
- data/lib/http_stub/configurator/state.rb +41 -0
- data/lib/http_stub/configurator/stub.rb +13 -0
- data/lib/http_stub/configurator/stub/stub.rb +75 -0
- data/lib/http_stub/{configurer/dsl/stub_builder_template.rb → configurator/stub/template.rb} +5 -5
- data/lib/http_stub/extensions/core/object.rb +17 -0
- data/lib/http_stub/rake/server_tasks.rb +2 -14
- data/lib/http_stub/rake/task_generators.rb +3 -3
- data/lib/http_stub/server.rb +110 -0
- data/lib/http_stub/server/application/application.rb +10 -6
- data/lib/http_stub/server/application/request_support.rb +2 -2
- data/lib/http_stub/server/application/routes/memory.rb +1 -6
- data/lib/http_stub/server/application/routes/scenario.rb +1 -11
- data/lib/http_stub/server/application/routes/session.rb +1 -1
- data/lib/http_stub/server/application/routes/status.rb +0 -10
- data/lib/http_stub/server/application/routes/stub.rb +2 -12
- data/lib/http_stub/server/daemon.rb +1 -10
- data/lib/http_stub/server/memory/controller.rb +2 -8
- data/lib/http_stub/server/memory/initial_state.rb +27 -0
- data/lib/http_stub/server/memory/memory.rb +6 -27
- data/lib/http_stub/server/registry.rb +3 -1
- data/lib/http_stub/server/request/factory.rb +3 -3
- data/lib/http_stub/server/response.rb +12 -6
- data/lib/http_stub/server/scenario.rb +2 -2
- data/lib/http_stub/server/scenario/controller.rb +3 -13
- data/lib/http_stub/server/scenario/registry.rb +25 -0
- data/lib/http_stub/server/scenario/scenario.rb +13 -8
- data/lib/http_stub/server/session.rb +0 -1
- data/lib/http_stub/server/session/controller.rb +7 -8
- data/lib/http_stub/server/session/identifier_strategy.rb +9 -2
- data/lib/http_stub/server/session/registry.rb +7 -13
- data/lib/http_stub/server/session/session.rb +4 -8
- data/lib/http_stub/server/stdout_logger.rb +13 -0
- data/lib/http_stub/server/stub.rb +3 -2
- data/lib/http_stub/server/stub/controller.rb +0 -10
- data/lib/http_stub/server/stub/empty.rb +2 -1
- data/lib/http_stub/server/stub/match/controller.rb +1 -1
- data/lib/http_stub/server/stub/match/exact_value_matcher.rb +2 -1
- data/lib/http_stub/server/stub/match/omitted_value_matcher.rb +1 -1
- data/lib/http_stub/server/stub/match/regexp_value_matcher.rb +1 -2
- data/lib/http_stub/server/stub/match/rule/body.rb +7 -29
- data/lib/http_stub/server/stub/match/rule/{json_body.rb → json_schema_body.rb} +1 -1
- data/lib/http_stub/server/stub/match/rule/method.rb +1 -1
- data/lib/http_stub/server/stub/match/rule/schema_body.rb +39 -0
- data/lib/http_stub/server/stub/match/rules.rb +6 -6
- data/lib/http_stub/server/stub/match/string_value_matcher.rb +1 -2
- data/lib/http_stub/server/stub/registry.rb +4 -4
- data/lib/http_stub/server/stub/response.rb +2 -6
- data/lib/http_stub/server/stub/response/blocks.rb +33 -0
- data/lib/http_stub/server/stub/response/body.rb +21 -0
- data/lib/http_stub/server/stub/response/file_body.rb +46 -0
- data/lib/http_stub/server/stub/response/headers.rb +24 -0
- data/lib/http_stub/server/stub/response/response.rb +52 -0
- data/lib/http_stub/server/stub/response/text_body.rb +32 -0
- data/lib/http_stub/server/stub/stub.rb +17 -11
- data/lib/http_stub/server/stub/triggers.rb +16 -5
- data/lib/http_stub/server/views/_file_body_response.haml +1 -0
- data/lib/http_stub/server/views/_response.haml +6 -1
- data/lib/http_stub/server/views/_text_body_response.haml +1 -0
- data/lib/http_stub/server/views/application.sass +31 -31
- data/lib/http_stub/version.rb +1 -1
- data/spec/acceptance/{configurer_part_spec.rb → configurator_part_spec.rb} +8 -8
- data/spec/acceptance/cross_origin_support_spec.rb +9 -11
- data/spec/acceptance/endpoint_template_spec.rb +5 -5
- data/spec/acceptance/scenario_spec.rb +8 -8
- data/spec/acceptance/server_defaults_spec.rb +3 -3
- data/spec/acceptance/server_memory_spec.rb +13 -5
- data/spec/acceptance/server_status_spec.rb +4 -21
- data/spec/acceptance/session_spec.rb +8 -11
- data/spec/acceptance/stub_body_request_matching_spec.rb +9 -9
- data/spec/acceptance/stub_control_values_spec.rb +74 -82
- data/spec/acceptance/stub_match_last_spec.rb +60 -80
- data/spec/acceptance/stub_match_list_spec.rb +30 -66
- data/spec/acceptance/stub_miss_list_spec.rb +19 -27
- data/spec/acceptance/stub_response_block_spec.rb +66 -0
- data/spec/acceptance/stub_spec.rb +109 -185
- data/spec/acceptance/stub_trigger_spec.rb +12 -89
- data/spec/helper.rb +32 -10
- data/spec/lib/http_stub/client/client_spec.rb +109 -0
- data/spec/lib/http_stub/client/request_integration_spec.rb +74 -0
- data/spec/lib/http_stub/client/request_spec.rb +32 -0
- data/spec/lib/http_stub/client/server_spec.rb +75 -0
- data/spec/lib/http_stub/client/session_spec.rb +117 -0
- data/spec/lib/http_stub/client_spec.rb +15 -0
- data/spec/lib/http_stub/{configurer/dsl/server_endpoint_template_spec.rb → configurator/endpoint_template_spec.rb} +49 -38
- data/spec/lib/http_stub/configurator/part_spec.rb +103 -0
- data/spec/lib/http_stub/configurator/scenario_spec.rb +162 -0
- data/spec/lib/http_stub/configurator/server_spec.rb +344 -0
- data/spec/lib/http_stub/configurator/state_spec.rb +113 -0
- data/spec/lib/http_stub/configurator/stub/stub_spec.rb +867 -0
- data/spec/lib/http_stub/{configurer/dsl/stub_builder_template_spec.rb → configurator/stub/template_spec.rb} +46 -44
- data/spec/lib/http_stub/configurator/stub_spec.rb +27 -0
- data/spec/lib/http_stub/configurator_spec.rb +113 -0
- data/spec/lib/http_stub/extensions/core/hash_spec.rb +3 -3
- data/spec/lib/http_stub/extensions/core/object_spec.rb +29 -0
- data/spec/lib/http_stub/rake/server_daemon_tasks_smoke_spec.rb +14 -9
- data/spec/lib/http_stub/rake/server_tasks_smoke_spec.rb +25 -53
- data/spec/lib/http_stub/rake/server_tasks_spec.rb +12 -55
- data/spec/lib/http_stub/server/application/application_spec.rb +4 -49
- data/spec/lib/http_stub/server/application/cross_origin_support_spec.rb +2 -5
- data/spec/lib/http_stub/server/application/request_support_integration_spec.rb +4 -4
- data/spec/lib/http_stub/server/application/request_support_spec.rb +16 -11
- data/spec/lib/http_stub/server/application/routes/memory_spec.rb +1 -21
- data/spec/lib/http_stub/server/application/routes/scenario_spec.rb +4 -56
- data/spec/lib/http_stub/server/application/routes/session_integration_spec.rb +1 -1
- data/spec/lib/http_stub/server/application/routes/status_spec.rb +2 -36
- data/spec/lib/http_stub/server/application/routes/stub_integration_spec.rb +3 -34
- data/spec/lib/http_stub/server/application/routes/stub_spec.rb +6 -55
- data/spec/lib/http_stub/server/daemon_integration_spec.rb +5 -1
- data/spec/lib/http_stub/server/daemon_spec.rb +8 -77
- data/spec/lib/http_stub/server/memory/controller_spec.rb +2 -28
- data/spec/lib/http_stub/server/memory/initial_state_spec.rb +57 -0
- data/spec/lib/http_stub/server/memory/memory_spec.rb +28 -116
- data/spec/lib/http_stub/server/registry_spec.rb +57 -2
- data/spec/lib/http_stub/server/request/factory_spec.rb +8 -6
- data/spec/lib/http_stub/server/response_spec.rb +32 -10
- data/spec/lib/http_stub/server/scenario/controller_spec.rb +14 -53
- data/spec/lib/http_stub/server/scenario/registry_spec.rb +147 -0
- data/spec/lib/http_stub/server/scenario/scenario_spec.rb +8 -10
- data/spec/lib/http_stub/server/scenario_spec.rb +1 -1
- data/spec/lib/http_stub/server/session/controller_spec.rb +4 -5
- data/spec/lib/http_stub/server/session/identifier_strategy_spec.rb +15 -48
- data/spec/lib/http_stub/server/session/registry_spec.rb +15 -28
- data/spec/lib/http_stub/server/session/session_spec.rb +13 -71
- data/spec/lib/http_stub/server/stdout_logger_spec.rb +17 -0
- data/spec/lib/http_stub/server/stub/controller_spec.rb +7 -65
- data/spec/lib/http_stub/server/stub/empty_spec.rb +8 -0
- data/spec/lib/http_stub/server/stub/match/controller_spec.rb +2 -2
- data/spec/lib/http_stub/server/stub/match/exact_value_matcher_spec.rb +49 -11
- data/spec/lib/http_stub/server/stub/match/hash_matcher_spec.rb +4 -4
- data/spec/lib/http_stub/server/stub/match/match_spec.rb +4 -4
- data/spec/lib/http_stub/server/stub/match/miss_spec.rb +2 -2
- data/spec/lib/http_stub/server/stub/match/omitted_value_matcher_spec.rb +31 -12
- data/spec/lib/http_stub/server/stub/match/regexp_value_matcher_spec.rb +20 -11
- data/spec/lib/http_stub/server/stub/match/rule/body_spec.rb +3 -3
- data/spec/lib/http_stub/server/stub/match/rule/{json_body_spec.rb → json_schema_body_spec.rb} +5 -5
- data/spec/lib/http_stub/server/stub/match/rule/method_spec.rb +42 -8
- data/spec/lib/http_stub/server/stub/match/rule/schema_body_spec.rb +64 -0
- data/spec/lib/http_stub/server/stub/match/rules_spec.rb +18 -18
- data/spec/lib/http_stub/server/stub/match/string_value_matcher_spec.rb +10 -63
- data/spec/lib/http_stub/server/stub/registry_integration_spec.rb +11 -28
- data/spec/lib/http_stub/server/stub/registry_spec.rb +6 -13
- data/spec/lib/http_stub/server/stub/response/blocks_spec.rb +64 -0
- data/spec/lib/http_stub/server/stub/response/body_spec.rb +52 -0
- data/spec/lib/http_stub/server/stub/response/file_body_spec.rb +117 -0
- data/spec/lib/http_stub/server/stub/response/headers_spec.rb +89 -0
- data/spec/lib/http_stub/server/stub/response/response_spec.rb +342 -0
- data/spec/lib/http_stub/server/stub/response/text_body_spec.rb +138 -0
- data/spec/lib/http_stub/server/stub/response_spec.rb +23 -32
- data/spec/lib/http_stub/server/stub/stub_spec.rb +33 -39
- data/spec/lib/http_stub/server/stub/triggers_spec.rb +47 -12
- data/spec/lib/http_stub/server/stub_spec.rb +1 -1
- data/spec/support/extensions/core/random.rb +23 -0
- data/spec/support/http_stub/configurator/scenario_builder.rb +35 -0
- data/spec/support/http_stub/configurator/scenario_fixture.rb +39 -0
- data/spec/support/http_stub/configurator/stub_builder.rb +112 -0
- data/spec/support/http_stub/configurator/stub_fixture.rb +58 -0
- data/spec/support/http_stub/configurator_fixture.rb +13 -0
- data/spec/support/http_stub/configurator_with_stub_builder_and_requester.rb +14 -0
- data/spec/support/http_stub/headers_fixture.rb +11 -0
- data/spec/support/http_stub/{html_view_excluding_request_details.rb → html_view_excluding_a_stub_request.rb} +2 -2
- data/spec/support/http_stub/{html_view_including_request_details.rb → html_view_including_a_stub_request.rb} +20 -12
- data/spec/support/http_stub/port.rb +12 -0
- data/spec/support/http_stub/server/application/http_stub_rack_application_test.rb +2 -3
- data/spec/support/http_stub/server/driver.rb +20 -15
- data/spec/support/http_stub/server/memory_fixture.rb +2 -2
- data/spec/support/http_stub/server/request/sinatra_request_fixture.rb +16 -0
- data/spec/support/http_stub/server/request_fixture.rb +11 -6
- data/spec/support/http_stub/server/scenario_fixture.rb +14 -2
- data/spec/support/http_stub/server/session_fixture.rb +2 -16
- data/spec/support/http_stub/server/silent_logger.rb +7 -0
- data/spec/support/http_stub/server/simple_request.rb +17 -0
- data/spec/support/http_stub/server/stub/match/match_fixture.rb +1 -1
- data/spec/support/http_stub/server/stub/response/blocks_fixture.rb +54 -0
- data/spec/support/http_stub/server/stub/response/file_body_fixture.rb +25 -0
- data/spec/support/http_stub/server/stub/response/text_body_fixture.rb +33 -0
- data/spec/support/http_stub/server/stub/response_builder.rb +24 -0
- data/spec/support/http_stub/server/stub/response_fixture.rb +15 -0
- data/spec/support/http_stub/server/stub_fixture.rb +21 -0
- data/spec/support/http_stub/server_integration.rb +9 -6
- data/spec/support/http_stub/stub_requester.rb +37 -0
- data/spec/support/object_convertable_to_json.rb +11 -0
- data/spec/support/rack/rack_application_test.rb +1 -1
- data/spec/support/rack/request_fixture.rb +22 -4
- metadata +166 -207
- data/lib/http_stub.rb +0 -131
- data/lib/http_stub/configurer.rb +0 -42
- data/lib/http_stub/configurer/dsl/request_attribute_referencer.rb +0 -19
- data/lib/http_stub/configurer/dsl/request_referencer.rb +0 -24
- data/lib/http_stub/configurer/dsl/scenario_builder.rb +0 -39
- data/lib/http_stub/configurer/dsl/server.rb +0 -80
- data/lib/http_stub/configurer/dsl/server_endpoint_template.rb +0 -23
- data/lib/http_stub/configurer/dsl/session.rb +0 -51
- data/lib/http_stub/configurer/dsl/session_endpoint_template.rb +0 -22
- data/lib/http_stub/configurer/dsl/session_factory.rb +0 -34
- data/lib/http_stub/configurer/dsl/stub_builder.rb +0 -65
- data/lib/http_stub/configurer/part.rb +0 -23
- data/lib/http_stub/configurer/request/controllable_value.rb +0 -19
- data/lib/http_stub/configurer/request/http/basic.rb +0 -27
- data/lib/http_stub/configurer/request/http/factory.rb +0 -33
- data/lib/http_stub/configurer/request/http/multipart.rb +0 -34
- data/lib/http_stub/configurer/request/omittable.rb +0 -26
- data/lib/http_stub/configurer/request/regexpable.rb +0 -33
- data/lib/http_stub/configurer/request/scenario.rb +0 -29
- data/lib/http_stub/configurer/request/stub.rb +0 -39
- data/lib/http_stub/configurer/request/stub_response.rb +0 -38
- data/lib/http_stub/configurer/request/stub_response_file.rb +0 -20
- data/lib/http_stub/configurer/request/triggers.rb +0 -25
- data/lib/http_stub/configurer/server/buffered_command_processor.rb +0 -24
- data/lib/http_stub/configurer/server/command.rb +0 -22
- data/lib/http_stub/configurer/server/command_processor.rb +0 -35
- data/lib/http_stub/configurer/server/configuration.rb +0 -33
- data/lib/http_stub/configurer/server/facade.rb +0 -61
- data/lib/http_stub/configurer/server/request_processor.rb +0 -30
- data/lib/http_stub/configurer/server/session_facade.rb +0 -57
- data/lib/http_stub/server/application/configuration.rb +0 -38
- data/lib/http_stub/server/application/response_pipeline.rb +0 -20
- data/lib/http_stub/server/application/response_support.rb +0 -19
- data/lib/http_stub/server/scenario/parser.rb +0 -17
- data/lib/http_stub/server/session/configuration.rb +0 -32
- data/lib/http_stub/server/status/controller.rb +0 -25
- data/lib/http_stub/server/stub/parser.rb +0 -17
- data/lib/http_stub/server/stub/payload.rb +0 -20
- data/lib/http_stub/server/stub/payload/base_uri_modifier.rb +0 -17
- data/lib/http_stub/server/stub/payload/response_body_modifier.rb +0 -21
- data/lib/http_stub/server/stub/response/attribute/body.rb +0 -32
- data/lib/http_stub/server/stub/response/attribute/headers.rb +0 -32
- data/lib/http_stub/server/stub/response/attribute/interpolator.rb +0 -26
- data/lib/http_stub/server/stub/response/attribute/interpolator/headers.rb +0 -27
- data/lib/http_stub/server/stub/response/attribute/interpolator/parameters.rb +0 -27
- data/lib/http_stub/server/stub/response/base.rb +0 -61
- data/lib/http_stub/server/stub/response/file.rb +0 -45
- data/lib/http_stub/server/stub/response/text.rb +0 -35
- data/lib/http_stub/server/views/_file_response.haml +0 -1
- data/lib/http_stub/server/views/_text_response.haml +0 -1
- data/spec/acceptance/configurer_initialization_spec.rb +0 -157
- data/spec/acceptance/request_reference_spec.rb +0 -42
- data/spec/lib/http_stub/configurer/dsl/request_attribute_referencer_spec.rb +0 -37
- data/spec/lib/http_stub/configurer/dsl/request_referencer_spec.rb +0 -37
- data/spec/lib/http_stub/configurer/dsl/scenario_builder_spec.rb +0 -201
- data/spec/lib/http_stub/configurer/dsl/server_spec.rb +0 -575
- data/spec/lib/http_stub/configurer/dsl/session_endpoint_template_spec.rb +0 -150
- data/spec/lib/http_stub/configurer/dsl/session_factory_spec.rb +0 -97
- data/spec/lib/http_stub/configurer/dsl/session_spec.rb +0 -210
- data/spec/lib/http_stub/configurer/dsl/stub_builder_spec.rb +0 -747
- data/spec/lib/http_stub/configurer/part_spec.rb +0 -103
- data/spec/lib/http_stub/configurer/request/controllable_value_spec.rb +0 -34
- data/spec/lib/http_stub/configurer/request/http/basic_spec.rb +0 -91
- data/spec/lib/http_stub/configurer/request/http/factory_spec.rb +0 -222
- data/spec/lib/http_stub/configurer/request/http/multipart_spec.rb +0 -118
- data/spec/lib/http_stub/configurer/request/omittable_spec.rb +0 -70
- data/spec/lib/http_stub/configurer/request/regexpable_spec.rb +0 -77
- data/spec/lib/http_stub/configurer/request/scenario_spec.rb +0 -69
- data/spec/lib/http_stub/configurer/request/stub_response_spec.rb +0 -195
- data/spec/lib/http_stub/configurer/request/stub_spec.rb +0 -231
- data/spec/lib/http_stub/configurer/request/triggers_spec.rb +0 -101
- data/spec/lib/http_stub/configurer/server/buffered_command_processor_spec.rb +0 -35
- data/spec/lib/http_stub/configurer/server/command_processor_integration_spec.rb +0 -75
- data/spec/lib/http_stub/configurer/server/command_spec.rb +0 -26
- data/spec/lib/http_stub/configurer/server/configuration_spec.rb +0 -139
- data/spec/lib/http_stub/configurer/server/facade_spec.rb +0 -235
- data/spec/lib/http_stub/configurer/server/request_processor_spec.rb +0 -100
- data/spec/lib/http_stub/configurer/server/session_facade_spec.rb +0 -285
- data/spec/lib/http_stub/configurer_spec.rb +0 -105
- data/spec/lib/http_stub/server/application/configuration_spec.rb +0 -59
- data/spec/lib/http_stub/server/application/response_pipeline_spec.rb +0 -29
- data/spec/lib/http_stub/server/application/response_support_spec.rb +0 -30
- data/spec/lib/http_stub/server/scenario/parser_spec.rb +0 -64
- data/spec/lib/http_stub/server/session/configuration_spec.rb +0 -94
- data/spec/lib/http_stub/server/status/controller_spec.rb +0 -47
- data/spec/lib/http_stub/server/stub/parser_spec.rb +0 -56
- data/spec/lib/http_stub/server/stub/payload/base_uri_modifier_spec.rb +0 -23
- data/spec/lib/http_stub/server/stub/payload/response_body_modifier_spec.rb +0 -84
- data/spec/lib/http_stub/server/stub/payload_spec.rb +0 -33
- data/spec/lib/http_stub/server/stub/response/attribute/body_spec.rb +0 -98
- data/spec/lib/http_stub/server/stub/response/attribute/headers_spec.rb +0 -73
- data/spec/lib/http_stub/server/stub/response/attribute/interpolator/headers_spec.rb +0 -53
- data/spec/lib/http_stub/server/stub/response/attribute/interpolator/parameters_spec.rb +0 -53
- data/spec/lib/http_stub/server/stub/response/attribute/interpolator_spec.rb +0 -41
- data/spec/lib/http_stub/server/stub/response/base_spec.rb +0 -217
- data/spec/lib/http_stub/server/stub/response/file_spec.rb +0 -197
- data/spec/lib/http_stub/server/stub/response/text_spec.rb +0 -182
- data/spec/resources/sample.pdf +0 -0
- data/spec/resources/sample.txt +0 -1
- data/spec/support/http_stub/configurer_integration.rb +0 -24
- data/spec/support/http_stub/empty_configurer.rb +0 -7
- data/spec/support/http_stub/scenario_fixture.rb +0 -33
- data/spec/support/http_stub/stub_fixture.rb +0 -125
- data/spec/support/http_stub/stub_registrator.rb +0 -83
@@ -1,32 +1,53 @@
|
|
1
1
|
describe "Stub control value acceptance" do
|
2
|
-
include_context "
|
2
|
+
include_context "server integration"
|
3
3
|
|
4
|
-
let(:
|
4
|
+
let(:configurator) { HttpStub::Examples::ConfiguratorWithStubControlValues }
|
5
5
|
|
6
|
-
context "when a stub
|
6
|
+
context "when a stub match uri has regular expression containing meta characters" do
|
7
7
|
|
8
|
-
context "
|
8
|
+
context "and a request is made whose uri matches the regular expression" do
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
let(:response) { HTTParty.get("#{server_uri}/match/stub/regexp/$key=value") }
|
11
|
+
|
12
|
+
it "replays the stubbed body" do
|
13
|
+
expect(response.body).to eql("Regular expression uri stub body")
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
context "and a request is made whose uri does not match the regular expression" do
|
19
|
+
|
20
|
+
let(:response) { HTTParty.get("#{server_uri}/stub/no_match/regexp") }
|
21
|
+
|
22
|
+
it "responds with a 404 status code" do
|
23
|
+
expect(response.code).to eql(404)
|
15
24
|
end
|
16
25
|
|
17
|
-
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when stub match headers" do
|
18
31
|
|
19
|
-
|
32
|
+
context "have regular expression values" do
|
20
33
|
|
21
|
-
|
22
|
-
|
34
|
+
let(:response) do
|
35
|
+
HTTParty.get("#{server_uri}/stub_with_regular_expression_headers", headers: { "key" => header_value })
|
36
|
+
end
|
37
|
+
|
38
|
+
context "and a request that matches is made" do
|
39
|
+
|
40
|
+
let(:header_value) { "matching_value" }
|
41
|
+
|
42
|
+
it "replays the stubbed response" do
|
43
|
+
expect(response.body).to eql("Regular expression headers stub body")
|
23
44
|
end
|
24
45
|
|
25
46
|
end
|
26
47
|
|
27
|
-
context "and a request
|
48
|
+
context "and a request that does not match is made" do
|
28
49
|
|
29
|
-
let(:
|
50
|
+
let(:header_value) { "does_not_match_value" }
|
30
51
|
|
31
52
|
it "responds with a 404 status code" do
|
32
53
|
expect(response.code).to eql(404)
|
@@ -36,33 +57,22 @@ describe "Stub control value acceptance" do
|
|
36
57
|
|
37
58
|
end
|
38
59
|
|
39
|
-
context "
|
40
|
-
|
41
|
-
before(:example) do
|
42
|
-
stub_server.add_stub! do |stub|
|
43
|
-
stub.match_requests(uri: "/stub_with_headers", method: :get, headers: { key: /^match.*/ })
|
44
|
-
stub.respond_with(status: 202, body: "Another stub body")
|
45
|
-
end
|
46
|
-
end
|
60
|
+
context "have values indicating they must be omitted" do
|
47
61
|
|
48
62
|
context "and a request that matches is made" do
|
49
63
|
|
50
|
-
let(:response)
|
51
|
-
HTTParty.get("#{server_uri}/stub_with_headers", headers: { "key" => "matching_value" })
|
52
|
-
end
|
64
|
+
let(:response) { HTTParty.get("#{server_uri}/stub_with_omitted_headers") }
|
53
65
|
|
54
66
|
it "replays the stubbed response" do
|
55
|
-
expect(response.
|
56
|
-
expect(response.body).to eql("Another stub body")
|
67
|
+
expect(response.body).to eql("Omitted headers stub body")
|
57
68
|
end
|
58
69
|
|
59
70
|
end
|
60
71
|
|
61
72
|
context "and a request that does not match is made" do
|
62
73
|
|
63
|
-
let(:
|
64
|
-
|
65
|
-
end
|
74
|
+
let(:headers) { { "key" => "must_be_omitted" } }
|
75
|
+
let(:response) { HTTParty.get("#{server_uri}/stub_with_omitted_headers", headers: headers) }
|
66
76
|
|
67
77
|
it "responds with a 404 status code" do
|
68
78
|
expect(response.code).to eql(404)
|
@@ -72,91 +82,73 @@ describe "Stub control value acceptance" do
|
|
72
82
|
|
73
83
|
end
|
74
84
|
|
75
|
-
|
85
|
+
end
|
76
86
|
|
77
|
-
|
87
|
+
context "when stub match parameters" do
|
78
88
|
|
79
|
-
|
80
|
-
stub_server.add_stub! do |stub|
|
81
|
-
stub.match_requests(uri: "/stub_with_parameters", method: :get, parameters: { key: /^match.*/ })
|
82
|
-
stub.respond_with(status: 202, body: "Another stub body")
|
83
|
-
end
|
84
|
-
end
|
89
|
+
context "have regular expression values" do
|
85
90
|
|
86
|
-
|
91
|
+
let(:response) do
|
92
|
+
HTTParty.get("#{server_uri}/stub_with_regular_expression_parameters", query: { "key" => parameter_value })
|
93
|
+
end
|
87
94
|
|
88
|
-
|
89
|
-
let(:response) { HTTParty.get("#{server_uri}/stub_with_parameters", query: parameters) }
|
95
|
+
context "and a request that matches is made" do
|
90
96
|
|
91
|
-
|
92
|
-
expect(response.code).to eql(202)
|
93
|
-
expect(response.body).to eql("Another stub body")
|
94
|
-
end
|
97
|
+
let(:parameter_value) { "matching_value" }
|
95
98
|
|
99
|
+
it "replays the stubbed response" do
|
100
|
+
expect(response.body).to eql("Regular expression parameters stub body")
|
96
101
|
end
|
97
102
|
|
98
|
-
|
103
|
+
end
|
99
104
|
|
100
|
-
|
101
|
-
let(:response) { HTTParty.get("#{server_uri}/stub_with_parameters", query: parameters) }
|
105
|
+
context "and a request that does not match is made" do
|
102
106
|
|
103
|
-
|
104
|
-
expect(response.code).to eql(404)
|
105
|
-
end
|
107
|
+
let(:parameter_value) { "does_not_match_value" }
|
106
108
|
|
109
|
+
it "responds with a 404 status code" do
|
110
|
+
expect(response.code).to eql(404)
|
107
111
|
end
|
108
112
|
|
109
113
|
end
|
110
114
|
|
111
|
-
|
112
|
-
|
113
|
-
before(:example) do
|
114
|
-
stub_server.add_stub! do |stub|
|
115
|
-
stub.match_requests(uri: "/stub_with_omitted_parameters", method: :get, parameters: { key: :omitted })
|
116
|
-
stub.respond_with(status: 202, body: "Omitted parameter stub body")
|
117
|
-
end
|
118
|
-
end
|
115
|
+
end
|
119
116
|
|
120
|
-
|
117
|
+
context "have values indicating they must be omitted" do
|
121
118
|
|
122
|
-
|
119
|
+
context "and a request that matches is made" do
|
123
120
|
|
124
|
-
|
125
|
-
expect(response.code).to eql(202)
|
126
|
-
expect(response.body).to eql("Omitted parameter stub body")
|
127
|
-
end
|
121
|
+
let(:response) { HTTParty.get("#{server_uri}/stub_with_omitted_parameters") }
|
128
122
|
|
123
|
+
it "replays the stubbed response" do
|
124
|
+
expect(response.body).to eql("Omitted parameters stub body")
|
129
125
|
end
|
130
126
|
|
131
|
-
|
127
|
+
end
|
132
128
|
|
133
|
-
|
134
|
-
let(:response) { HTTParty.get("#{server_uri}/stub_with_omitted_parameters", query: parameters) }
|
129
|
+
context "and a request that does not match is made" do
|
135
130
|
|
136
|
-
|
137
|
-
|
138
|
-
end
|
131
|
+
let(:parameters) { { "key" => "must_be_omitted" } }
|
132
|
+
let(:response) { HTTParty.get("#{server_uri}/stub_with_omitted_parameters", query: parameters) }
|
139
133
|
|
134
|
+
it "responds with a 404 status code" do
|
135
|
+
expect(response.code).to eql(404)
|
140
136
|
end
|
141
137
|
|
142
138
|
end
|
143
139
|
|
144
140
|
end
|
145
141
|
|
146
|
-
|
147
|
-
|
148
|
-
before(:example) do
|
149
|
-
stub_server.add_stub! { match_requests(uri: "/some_stub_path", method: :get).respond_with(delay_in_seconds: 1) }
|
150
|
-
end
|
142
|
+
end
|
151
143
|
|
152
|
-
|
153
|
-
start_time = Time.now
|
144
|
+
context "when stub has a response delay" do
|
154
145
|
|
155
|
-
|
146
|
+
it "delays the response by the time provided" do
|
147
|
+
start_time = Time.now
|
156
148
|
|
157
|
-
|
158
|
-
end
|
149
|
+
HTTParty.get("#{server_uri}/stub_with_response_delay")
|
159
150
|
|
151
|
+
expect(Time.now - start_time).to be >= 1.0
|
160
152
|
end
|
161
153
|
|
162
154
|
end
|
@@ -1,114 +1,107 @@
|
|
1
1
|
describe "Stub matches last acceptance" do
|
2
|
-
include_context "
|
2
|
+
include_context "server integration"
|
3
3
|
|
4
4
|
describe "GET /http_stub/stubs/matches/last" do
|
5
|
+
include_context "configurator with stub builder and requester"
|
5
6
|
|
6
|
-
let(:
|
7
|
-
let(:
|
8
|
-
let(:request_parameters) { { uri: request_uri, method: request_method } }
|
9
|
-
let(:response) { HTTParty.get("#{server_uri}/http_stub/stubs/matches/last", query: request_parameters) }
|
10
|
-
let(:json_response) { JSON.parse(response.body) }
|
11
|
-
|
12
|
-
before(:example) { configure_stub_registrator }
|
13
|
-
|
14
|
-
context "when a request has been made matching a stub" do
|
7
|
+
let(:request_prior_to_last_match_request) { stub_requester.issue_matching_request}
|
8
|
+
let(:ensure_stub_request_is_issued) { request_prior_to_last_match_request }
|
15
9
|
|
16
|
-
|
17
|
-
|
10
|
+
let(:request_parameters) { { uri: stub_match_rules[:uri], method: stub_match_rules[:method] } }
|
11
|
+
let(:last_match_request) { HTTParty.get("#{server_uri}/http_stub/stubs/matches/last", query: request_parameters) }
|
12
|
+
let(:response) do
|
13
|
+
request_prior_to_last_match_request
|
14
|
+
last_match_request
|
15
|
+
end
|
16
|
+
let(:json_response) { JSON.parse(response.body) }
|
18
17
|
|
19
|
-
|
20
|
-
end
|
18
|
+
context "when a request has been made matching a stub against request headers" do
|
21
19
|
|
22
20
|
it "returns a 200 response" do
|
23
21
|
expect(response.code).to eql(200)
|
24
22
|
end
|
25
23
|
|
26
|
-
it "returns JSON containing the requests uri" do
|
27
|
-
expect_match_request_to_include("uri" =>
|
24
|
+
it "returns JSON containing the matching requests uri" do
|
25
|
+
expect_match_request_to_include("uri" => stub_match_rules[:uri])
|
28
26
|
end
|
29
27
|
|
30
|
-
it "returns JSON containing the requests method" do
|
31
|
-
expect_match_request_to_include("method" =>
|
28
|
+
it "returns JSON containing the matching requests method" do
|
29
|
+
expect_match_request_to_include("method" => stub_match_rules[:method])
|
32
30
|
end
|
33
31
|
|
34
|
-
it "returns JSON containing the requests headers whose names are in uppercase" do
|
35
|
-
|
32
|
+
it "returns JSON containing the matching requests headers whose names are in uppercase" do
|
33
|
+
stub_match_rules[:headers].each do |header_key, expected_header_value|
|
36
34
|
expect_match_request_to_include("headers" => hash_including(header_key.upcase => expected_header_value))
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
40
|
-
context "when the request contains parameters" do
|
41
|
-
|
42
|
-
def configure_stub_registrator
|
43
|
-
stub_registrator.with_request_parameters
|
44
|
-
end
|
45
|
-
|
46
|
-
it "returns JSON containing the requests parameters" do
|
47
|
-
stub_registrator.request_parameters.each do |expected_parameter_key, expected_parameter_value|
|
48
|
-
expect_match_request_to_include(
|
49
|
-
"parameters" => hash_including(expected_parameter_key => expected_parameter_value)
|
50
|
-
)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
context "when the request contains a body" do
|
57
|
-
|
58
|
-
def configure_stub_registrator
|
59
|
-
stub_registrator.with_request_body
|
60
|
-
end
|
61
|
-
|
62
|
-
it "returns JSON containing the requests body" do
|
63
|
-
expect_match_request_to_include("body" => stub_registrator.request_body)
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
38
|
it "returns JSON containing the matches response status" do
|
69
|
-
expect_match_response_to_include("status" =>
|
39
|
+
expect_match_response_to_include("status" => expected_match_response[:status])
|
70
40
|
end
|
71
41
|
|
72
42
|
it "returns JSON containing the matches response headers" do
|
73
|
-
|
43
|
+
expected_match_response[:headers].each do |expected_header_key, expected_header_value|
|
74
44
|
expect_match_response_to_include("headers" => hash_including(expected_header_key => expected_header_value))
|
75
45
|
end
|
76
46
|
end
|
77
47
|
|
78
48
|
it "returns JSON containing the matches response body" do
|
79
|
-
expect_match_response_to_include("body" =>
|
49
|
+
expect_match_response_to_include("body" => expected_match_response[:body])
|
80
50
|
end
|
81
51
|
|
82
52
|
it "returns JSON containing the uri of the matched stub" do
|
83
|
-
expect_match_stub_to_include("uri" =>
|
53
|
+
expect_match_stub_to_include("uri" => stub_builder.stub_uri)
|
84
54
|
end
|
85
55
|
|
86
56
|
it "returns JSON containing the request match rules of the matched stub" do
|
87
|
-
expect_match_stub_to_include("match_rules" => hash_including("uri" =>
|
57
|
+
expect_match_stub_to_include("match_rules" => hash_including("uri" => stub_match_rules[:uri]))
|
88
58
|
end
|
89
59
|
|
90
60
|
it "returns JSON containing the configured response of the matched stub" do
|
91
|
-
expect_match_stub_to_include("response" => hash_including("status" =>
|
61
|
+
expect_match_stub_to_include("response" => hash_including("status" => stub_response[:status]))
|
92
62
|
end
|
93
63
|
|
94
64
|
end
|
95
65
|
|
96
|
-
context "when a request has been made matching a stub
|
66
|
+
context "when a request has been made matching a stub against request parameters" do
|
67
|
+
|
68
|
+
before(:example) { stub_builder.with_request_parameters! }
|
97
69
|
|
98
|
-
|
99
|
-
|
100
|
-
stub_registrator.with_request_interpolation
|
70
|
+
it "returns JSON containing the requests parameters" do
|
71
|
+
ensure_stub_request_is_issued
|
101
72
|
|
102
|
-
|
73
|
+
stub_request[:parameters].each do |expected_parameter_key, expected_parameter_value|
|
74
|
+
expect_match_request_to_include(
|
75
|
+
"parameters" => hash_including(expected_parameter_key => expected_parameter_value)
|
76
|
+
)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
context "when a request has been made matching a stub against a body" do
|
83
|
+
|
84
|
+
it "returns JSON containing the requests body" do
|
85
|
+
ensure_stub_request_is_issued
|
103
86
|
|
104
|
-
|
87
|
+
expect_match_request_to_include("body" => stub_request[:body])
|
105
88
|
end
|
106
89
|
|
90
|
+
end
|
91
|
+
|
92
|
+
context "when a request has been made matching a stub whose response includes request interpolation" do
|
93
|
+
|
94
|
+
before(:example) { stub_builder.with_request_parameters!.and.with_request_interpolation! }
|
95
|
+
|
107
96
|
it "returns a 200 response" do
|
108
97
|
expect(response.code).to eql(200)
|
109
98
|
end
|
110
99
|
|
111
|
-
it "returns JSON containing the
|
100
|
+
it "returns JSON containing the response block source code of the matched stub" do
|
101
|
+
expect_match_stub_to_include("response" => hash_including("blocks" => [ stub_response[:block].source ]))
|
102
|
+
end
|
103
|
+
|
104
|
+
it "returns JSON containing the matches response headers with interpolated request values" do
|
112
105
|
expected_stub_response_headers = {
|
113
106
|
"header_reference" => "request header value 2",
|
114
107
|
"parameter_reference" => "parameter value 2"
|
@@ -119,7 +112,7 @@ describe "Stub matches last acceptance" do
|
|
119
112
|
end
|
120
113
|
end
|
121
114
|
|
122
|
-
it "returns JSON containing the matches response body with interpolated request
|
115
|
+
it "returns JSON containing the matches response body with interpolated request values" do
|
123
116
|
expected_stub_response_body = "header: request header value 3, parameter: parameter value 3"
|
124
117
|
|
125
118
|
expect_match_response_to_include("body" => expected_stub_response_body)
|
@@ -129,7 +122,7 @@ describe "Stub matches last acceptance" do
|
|
129
122
|
|
130
123
|
context "when a request has been made that does not match a stub" do
|
131
124
|
|
132
|
-
|
125
|
+
let(:request_prior_to_last_match_request) { stub_requester.issue_non_matching_request }
|
133
126
|
|
134
127
|
it "returns a 404 response" do
|
135
128
|
expect(response.code).to eql(404)
|
@@ -137,9 +130,9 @@ describe "Stub matches last acceptance" do
|
|
137
130
|
|
138
131
|
end
|
139
132
|
|
140
|
-
context "when
|
133
|
+
context "when no request has been made" do
|
141
134
|
|
142
|
-
|
135
|
+
let(:request_prior_to_last_match_request) { nil }
|
143
136
|
|
144
137
|
it "returns a 404 response" do
|
145
138
|
expect(response.code).to eql(404)
|
@@ -147,20 +140,6 @@ describe "Stub matches last acceptance" do
|
|
147
140
|
|
148
141
|
end
|
149
142
|
|
150
|
-
context "when a request has been made configuring a scenario" do
|
151
|
-
|
152
|
-
before(:example) { stub_registrator.register_scenario }
|
153
|
-
|
154
|
-
it "returns a 404 response" do
|
155
|
-
expect(response.code).to eql(404)
|
156
|
-
end
|
157
|
-
|
158
|
-
end
|
159
|
-
|
160
|
-
def configure_stub_registrator
|
161
|
-
# intentionally blank
|
162
|
-
end
|
163
|
-
|
164
143
|
def expect_match_request_to_include(hash)
|
165
144
|
expect(json_response).to(include("request" => hash_including(hash)))
|
166
145
|
end
|
@@ -170,7 +149,8 @@ describe "Stub matches last acceptance" do
|
|
170
149
|
end
|
171
150
|
|
172
151
|
def expect_match_stub_to_include(hash)
|
173
|
-
|
152
|
+
response_hash = json_response
|
153
|
+
expect(response_hash).to(include("stub" => hash_including(hash)))
|
174
154
|
end
|
175
155
|
|
176
156
|
end
|