http_stub 0.27.0 → 0.28.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/http_stub/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
data/lib/http_stub/{configurer/dsl/stub_builder_template.rb → configurator/stub/template.rb}
RENAMED
@@ -1,19 +1,19 @@
|
|
1
1
|
module HttpStub
|
2
|
-
module
|
3
|
-
module
|
2
|
+
module Configurator
|
3
|
+
module Stub
|
4
4
|
|
5
|
-
class
|
5
|
+
class Template
|
6
6
|
|
7
7
|
attr_reader :template
|
8
8
|
|
9
9
|
delegate :match_requests, :schema, :respond_with, :trigger, :invoke, to: :@template
|
10
10
|
|
11
11
|
def initialize(parent_template=nil, &block)
|
12
|
-
@template = HttpStub::
|
12
|
+
@template = HttpStub::Configurator::Stub.create(parent_template.try(:template), &block)
|
13
13
|
end
|
14
14
|
|
15
15
|
def build_stub(response_overrides={}, &block)
|
16
|
-
HttpStub::
|
16
|
+
HttpStub::Configurator::Stub.create(@template) do |stub|
|
17
17
|
stub.respond_with(response_overrides)
|
18
18
|
stub.invoke(&block) if block_given?
|
19
19
|
end
|
@@ -6,28 +6,16 @@ module HttpStub
|
|
6
6
|
def initialize(args)
|
7
7
|
namespace args[:name] do
|
8
8
|
define_start_task(args)
|
9
|
-
define_initialize_task(args) if args[:configurer]
|
10
9
|
end
|
11
10
|
end
|
12
11
|
|
13
12
|
private
|
14
13
|
|
15
14
|
def define_start_task(args)
|
15
|
+
raise "configurator must be specified" unless args[:configurator]
|
16
16
|
namespace :start do
|
17
17
|
desc "Start stub #{args[:name]} in the foreground"
|
18
|
-
task(:foreground) {
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def define_initialize_task(args)
|
23
|
-
desc "Configure stub #{args[:name]}"
|
24
|
-
task(:configure) { args[:configurer].initialize! }
|
25
|
-
end
|
26
|
-
|
27
|
-
def run_application(args)
|
28
|
-
HttpStub::Server::Application::Application.instance_eval do
|
29
|
-
configure(args)
|
30
|
-
run!
|
18
|
+
task(:foreground) { HttpStub::Server.start(args[:configurator]) }
|
31
19
|
end
|
32
20
|
end
|
33
21
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
|
1
|
+
require_relative '../server'
|
2
2
|
require 'rake/tasklib' unless defined? ::Rake::TaskLib
|
3
3
|
|
4
4
|
require 'http_server_manager/rake/task_generators'
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
require_relative 'server_tasks'
|
7
|
+
require_relative 'server_daemon_tasks'
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require_relative 'extensions/sinatra/namespace'
|
3
|
+
require 'sinatra/partial'
|
4
|
+
require 'json'
|
5
|
+
require 'json-schema'
|
6
|
+
require 'http_server_manager'
|
7
|
+
require 'method_source'
|
8
|
+
require 'haml'
|
9
|
+
require 'sass'
|
10
|
+
|
11
|
+
require 'active_support/core_ext/module/aliasing'
|
12
|
+
require 'active_support/core_ext/module/delegation'
|
13
|
+
require 'active_support/core_ext/object/blank'
|
14
|
+
require 'active_support/core_ext/object/try'
|
15
|
+
require 'active_support/core_ext/string/inflections'
|
16
|
+
require 'active_support/core_ext/hash/slice'
|
17
|
+
require 'active_support/core_ext/hash/deep_merge'
|
18
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
19
|
+
|
20
|
+
require_relative 'extensions/core/object'
|
21
|
+
require_relative 'extensions/core/hash/formatted'
|
22
|
+
require_relative 'extensions/core/hash/indifferent_and_insensitive_access'
|
23
|
+
require_relative 'extensions/core/hash/with_indifferent_and_insensitive_access'
|
24
|
+
require_relative 'extensions/core/hash'
|
25
|
+
require_relative 'extensions/core/uri'
|
26
|
+
|
27
|
+
require_relative 'extensions/rack/handler'
|
28
|
+
|
29
|
+
require_relative 'server/stdout_logger'
|
30
|
+
require_relative 'server/request/parameters'
|
31
|
+
require_relative 'server/request/headers'
|
32
|
+
require_relative 'server/request/sinatra_request'
|
33
|
+
require_relative 'server/request/request'
|
34
|
+
require_relative 'server/request/factory'
|
35
|
+
require_relative 'server/registry'
|
36
|
+
require_relative 'server/stub/match/omitted_value_matcher'
|
37
|
+
require_relative 'server/stub/match/regexp_value_matcher'
|
38
|
+
require_relative 'server/stub/match/exact_value_matcher'
|
39
|
+
require_relative 'server/stub/match/string_value_matcher'
|
40
|
+
require_relative 'server/stub/match/hash_matcher'
|
41
|
+
require_relative 'server/stub/match/rule/truthy'
|
42
|
+
require_relative 'server/stub/match/rule/uri'
|
43
|
+
require_relative 'server/stub/match/rule/method'
|
44
|
+
require_relative 'server/stub/match/rule/headers'
|
45
|
+
require_relative 'server/stub/match/rule/parameters'
|
46
|
+
require_relative 'server/stub/match/rule/simple_body'
|
47
|
+
require_relative 'server/stub/match/rule/json_schema_body'
|
48
|
+
require_relative 'server/stub/match/rule/schema_body'
|
49
|
+
require_relative 'server/stub/match/rule/body'
|
50
|
+
require_relative 'server/stub/match/rules'
|
51
|
+
require_relative 'server/stub/response/headers'
|
52
|
+
require_relative 'server/stub/response/blocks'
|
53
|
+
require_relative 'server/stub/response/text_body'
|
54
|
+
require_relative 'server/stub/response/file_body'
|
55
|
+
require_relative 'server/stub/response/body'
|
56
|
+
require_relative 'server/stub/response/response'
|
57
|
+
require_relative 'server/stub/response'
|
58
|
+
require_relative 'server/response'
|
59
|
+
require_relative 'server/stub/triggers'
|
60
|
+
require_relative 'server/stub/stub'
|
61
|
+
require_relative 'server/stub/empty'
|
62
|
+
require_relative 'server/stub/match/match'
|
63
|
+
require_relative 'server/stub/match/miss'
|
64
|
+
require_relative 'server/stub/match/controller'
|
65
|
+
require_relative 'server/stub/registry'
|
66
|
+
require_relative 'server/stub/controller'
|
67
|
+
require_relative 'server/stub'
|
68
|
+
require_relative 'server/session'
|
69
|
+
require_relative 'server/session/identifier_strategy'
|
70
|
+
require_relative 'server/session/empty'
|
71
|
+
require_relative 'server/session/session'
|
72
|
+
require_relative 'server/session/registry'
|
73
|
+
require_relative 'server/session/controller'
|
74
|
+
require_relative 'server/scenario/links'
|
75
|
+
require_relative 'server/scenario/trigger'
|
76
|
+
require_relative 'server/scenario/not_found_error'
|
77
|
+
require_relative 'server/scenario/scenario'
|
78
|
+
require_relative 'server/scenario/registry'
|
79
|
+
require_relative 'server/scenario/controller'
|
80
|
+
require_relative 'server/scenario'
|
81
|
+
require_relative 'server/memory/initial_state'
|
82
|
+
require_relative 'server/memory/memory'
|
83
|
+
require_relative 'server/memory/controller'
|
84
|
+
require_relative 'server/application/request_support'
|
85
|
+
require_relative 'server/application/cross_origin_support'
|
86
|
+
require_relative 'server/application/session_uri_support'
|
87
|
+
require_relative 'server/application/text_formatting_support'
|
88
|
+
require_relative 'server/application/routes/resource'
|
89
|
+
require_relative 'server/application/routes/status'
|
90
|
+
require_relative 'server/application/routes/stub'
|
91
|
+
require_relative 'server/application/routes/session'
|
92
|
+
require_relative 'server/application/routes/scenario'
|
93
|
+
require_relative 'server/application/routes/memory'
|
94
|
+
require_relative 'server/application/application'
|
95
|
+
require_relative 'server/daemon'
|
96
|
+
|
97
|
+
module HttpStub
|
98
|
+
|
99
|
+
module Server
|
100
|
+
|
101
|
+
def self.start(configurator)
|
102
|
+
HttpStub::Server::Application::Application.instance_eval do
|
103
|
+
configure(configurator)
|
104
|
+
run!
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
@@ -14,19 +14,23 @@ module HttpStub
|
|
14
14
|
enable :dump_errors, :logging, :partial_underscores
|
15
15
|
disable :protection, :cross_origin_support
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
class << self
|
18
|
+
|
19
|
+
attr_reader :configurator_state
|
20
|
+
|
21
|
+
def configure(configurator)
|
22
|
+
@configurator_state = configurator.state
|
23
|
+
@configurator_state.application_settings.each { |name, value| set(name, value) }
|
24
|
+
end
|
25
|
+
|
20
26
|
end
|
21
27
|
|
22
28
|
def initialize
|
23
|
-
@
|
24
|
-
@server_memory = HttpStub::Server::Memory::Memory.new(@session_configuration)
|
29
|
+
@server_memory = HttpStub::Server::Memory::Memory.new(self.class.configurator_state)
|
25
30
|
super()
|
26
31
|
end
|
27
32
|
|
28
33
|
include HttpStub::Server::Application::RequestSupport
|
29
|
-
include HttpStub::Server::Application::ResponseSupport
|
30
34
|
|
31
35
|
register HttpStub::Server::Application::CrossOriginSupport
|
32
36
|
|
@@ -4,7 +4,7 @@ module HttpStub
|
|
4
4
|
|
5
5
|
module RequestSupport
|
6
6
|
|
7
|
-
STUBBABLE_REQUEST_METHODS =
|
7
|
+
STUBBABLE_REQUEST_METHODS = %i{ get post put patch delete options }.freeze
|
8
8
|
|
9
9
|
private_constant :STUBBABLE_REQUEST_METHODS
|
10
10
|
|
@@ -12,7 +12,7 @@ module HttpStub
|
|
12
12
|
|
13
13
|
def initialize
|
14
14
|
super()
|
15
|
-
@request_factory = HttpStub::Server::Request::Factory.new(
|
15
|
+
@request_factory = HttpStub::Server::Request::Factory.new(settings.session_identifier, @server_memory)
|
16
16
|
end
|
17
17
|
|
18
18
|
def establish_http_stub_request
|
@@ -7,7 +7,7 @@ module HttpStub
|
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
super()
|
10
|
-
@memory_controller = HttpStub::Server::Memory::Controller.new(@
|
10
|
+
@memory_controller = HttpStub::Server::Memory::Controller.new(@server_memory)
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.included(application)
|
@@ -19,11 +19,6 @@ module HttpStub
|
|
19
19
|
haml :stubs, {}, stubs: @memory_controller.find_stubs
|
20
20
|
end
|
21
21
|
|
22
|
-
delete do
|
23
|
-
@memory_controller.reset(logger)
|
24
|
-
halt 200, "OK"
|
25
|
-
end
|
26
|
-
|
27
22
|
end
|
28
23
|
|
29
24
|
end
|
@@ -15,11 +15,6 @@ module HttpStub
|
|
15
15
|
|
16
16
|
namespace "/http_stub/scenarios" do
|
17
17
|
|
18
|
-
post do
|
19
|
-
response = @scenario_controller.register(http_stub_request, logger)
|
20
|
-
@response_pipeline.process(response)
|
21
|
-
end
|
22
|
-
|
23
18
|
get do
|
24
19
|
pass unless http_stub_request.parameters[:name]
|
25
20
|
haml :scenario, {}, scenario: @scenario_controller.find(http_stub_request, logger)
|
@@ -31,12 +26,7 @@ module HttpStub
|
|
31
26
|
|
32
27
|
post "/activate" do
|
33
28
|
response = @scenario_controller.activate(http_stub_request, logger)
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
delete do
|
38
|
-
@scenario_controller.clear(logger)
|
39
|
-
halt 200, "OK"
|
29
|
+
response.serve_on(self)
|
40
30
|
end
|
41
31
|
|
42
32
|
end
|
@@ -7,7 +7,7 @@ module HttpStub
|
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
super()
|
10
|
-
@session_controller = HttpStub::Server::Session::Controller.new(@
|
10
|
+
@session_controller = HttpStub::Server::Session::Controller.new(@server_memory)
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.included(application)
|
@@ -5,22 +5,12 @@ module HttpStub
|
|
5
5
|
|
6
6
|
module Status
|
7
7
|
|
8
|
-
def initialize
|
9
|
-
super()
|
10
|
-
@status_controller = HttpStub::Server::Status::Controller.new(@session_configuration, @server_memory)
|
11
|
-
end
|
12
|
-
|
13
8
|
def self.included(application)
|
14
9
|
application.instance_eval do
|
15
10
|
|
16
11
|
namespace "/http_stub/status" do
|
17
12
|
|
18
13
|
get do
|
19
|
-
halt 200, @status_controller.current
|
20
|
-
end
|
21
|
-
|
22
|
-
post "/initialized" do
|
23
|
-
@status_controller.initialized
|
24
14
|
halt 200, "OK"
|
25
15
|
end
|
26
16
|
|
@@ -16,11 +16,6 @@ module HttpStub
|
|
16
16
|
|
17
17
|
namespace "/http_stub/stubs" do
|
18
18
|
|
19
|
-
post do
|
20
|
-
response = @stub_controller.register(http_stub_request, logger)
|
21
|
-
@response_pipeline.process(response)
|
22
|
-
end
|
23
|
-
|
24
19
|
get do
|
25
20
|
haml :stubs, {}, stubs: @stub_controller.find_all(http_stub_request)
|
26
21
|
end
|
@@ -30,11 +25,6 @@ module HttpStub
|
|
30
25
|
halt 200, "OK"
|
31
26
|
end
|
32
27
|
|
33
|
-
delete do
|
34
|
-
@stub_controller.clear(http_stub_request, logger)
|
35
|
-
halt 200, "OK"
|
36
|
-
end
|
37
|
-
|
38
28
|
namespace "/matches" do
|
39
29
|
|
40
30
|
get do
|
@@ -43,7 +33,7 @@ module HttpStub
|
|
43
33
|
|
44
34
|
get "/last" do
|
45
35
|
response = @stub_match_controller.last_match(http_stub_request, logger)
|
46
|
-
|
36
|
+
response.serve_on(self)
|
47
37
|
end
|
48
38
|
|
49
39
|
end
|
@@ -61,7 +51,7 @@ module HttpStub
|
|
61
51
|
|
62
52
|
any_request_method "*" do
|
63
53
|
response = @stub_controller.match(http_stub_request, logger)
|
64
|
-
|
54
|
+
response.serve_on(self)
|
65
55
|
end
|
66
56
|
|
67
57
|
end
|
@@ -16,19 +16,10 @@ module HttpStub
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def initialize(args)
|
19
|
-
|
20
|
-
default_args = { host: "localhost", ping_uri: "/http_stub/status" }
|
21
|
-
default_args.merge!(host: @configurer.stub_server.host, port: @configurer.stub_server.port) if @configurer
|
19
|
+
default_args = { host: "localhost", port: args[:configurator].state.port, ping_uri: "/http_stub/status" }
|
22
20
|
super(default_args.merge(args))
|
23
21
|
end
|
24
22
|
|
25
|
-
def start!
|
26
|
-
super
|
27
|
-
return unless @configurer
|
28
|
-
@configurer.initialize!
|
29
|
-
logger.info "#{@name} initialized"
|
30
|
-
end
|
31
|
-
|
32
23
|
def start_command
|
33
24
|
"rake #{@name}:start:foreground"
|
34
25
|
end
|
@@ -4,20 +4,14 @@ module HttpStub
|
|
4
4
|
|
5
5
|
class Controller
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
9
|
-
@server_memory = server_memory
|
7
|
+
def initialize(server_memory)
|
8
|
+
@server_memory = server_memory
|
10
9
|
end
|
11
10
|
|
12
11
|
def find_stubs
|
13
12
|
@server_memory.stubs
|
14
13
|
end
|
15
14
|
|
16
|
-
def reset(logger)
|
17
|
-
@session_configuration.reset
|
18
|
-
@server_memory.reset(logger)
|
19
|
-
end
|
20
|
-
|
21
15
|
end
|
22
16
|
|
23
17
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module HttpStub
|
2
|
+
module Server
|
3
|
+
module Memory
|
4
|
+
|
5
|
+
class InitialState
|
6
|
+
|
7
|
+
def initialize(configurator_state)
|
8
|
+
@configurator_state = configurator_state
|
9
|
+
end
|
10
|
+
|
11
|
+
def load_scenarios
|
12
|
+
@configurator_state.scenario_hashes.map { |hash| HttpStub::Server::Scenario.create(hash) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def load_stubs(scenario_registry)
|
16
|
+
initial_stubs = @configurator_state.stub_hashes.map { |hash| HttpStub::Server::Stub.create(hash) }
|
17
|
+
activated_stubs = scenario_registry.find_all(&:initially_activated?).map do |activated_scenario|
|
18
|
+
scenario_registry.stubs_activated_by(activated_scenario, HttpStub::Server::StdoutLogger)
|
19
|
+
end.flatten
|
20
|
+
initial_stubs + activated_stubs
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|