http_stub 0.15.5 → 0.16.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/lib/http_stub.rb +37 -27
  3. data/lib/http_stub/configurer.rb +2 -2
  4. data/lib/http_stub/configurer/dsl/deprecated.rb +60 -0
  5. data/lib/http_stub/configurer/{server/dsl.rb → dsl/sanctioned.rb} +18 -18
  6. data/lib/http_stub/configurer/dsl/scenario_activator.rb +15 -0
  7. data/lib/http_stub/configurer/dsl/scenario_builder.rb +37 -0
  8. data/lib/http_stub/configurer/dsl/stub_activator_builder.rb +24 -0
  9. data/lib/http_stub/configurer/{request → dsl}/stub_builder.rb +4 -3
  10. data/lib/http_stub/configurer/dsl/stub_builder_producer.rb +21 -0
  11. data/lib/http_stub/configurer/request/http/factory.rb +8 -2
  12. data/lib/http_stub/configurer/request/scenario.rb +29 -0
  13. data/lib/http_stub/configurer/server/facade.rb +7 -7
  14. data/lib/http_stub/server/application.rb +21 -14
  15. data/lib/http_stub/server/registry.rb +7 -3
  16. data/lib/http_stub/server/response.rb +3 -3
  17. data/lib/http_stub/server/scenario.rb +12 -0
  18. data/lib/http_stub/server/scenario/activator.rb +25 -0
  19. data/lib/http_stub/server/scenario/controller.rb +36 -0
  20. data/lib/http_stub/server/scenario/instance.rb +36 -0
  21. data/lib/http_stub/server/scenario/request_parser.rb +19 -0
  22. data/lib/http_stub/server/stub.rb +3 -23
  23. data/lib/http_stub/server/stub/controller.rb +30 -0
  24. data/lib/http_stub/server/stub/exact_value_matcher.rb +15 -0
  25. data/lib/http_stub/server/stub/hash_with_string_value_matchers.rb +22 -0
  26. data/lib/http_stub/server/stub/headers.rb +19 -0
  27. data/lib/http_stub/server/stub/instance.rb +31 -0
  28. data/lib/http_stub/server/stub/method.rb +23 -0
  29. data/lib/http_stub/server/stub/omitted_value_matcher.rb +21 -0
  30. data/lib/http_stub/server/stub/payload_file_consolidator.rb +18 -0
  31. data/lib/http_stub/server/stub/regexp_value_matcher.rb +16 -0
  32. data/lib/http_stub/server/stub/registry.rb +31 -0
  33. data/lib/http_stub/server/stub/request_header_parser.rb +19 -0
  34. data/lib/http_stub/server/stub/request_headers.rb +28 -0
  35. data/lib/http_stub/server/stub/request_parameters.rb +23 -0
  36. data/lib/http_stub/server/stub/request_parser.rb +17 -0
  37. data/lib/http_stub/server/stub/response.rb +16 -0
  38. data/lib/http_stub/server/stub/response/base.rb +64 -0
  39. data/lib/http_stub/server/stub/response/file.rb +36 -0
  40. data/lib/http_stub/server/stub/response/text.rb +19 -0
  41. data/lib/http_stub/server/stub/string_value_matcher.rb +31 -0
  42. data/lib/http_stub/server/stub/triggers.rb +25 -0
  43. data/lib/http_stub/server/stub/uri.rb +23 -0
  44. data/lib/http_stub/server/views/_scenario.haml +16 -0
  45. data/lib/http_stub/server/views/application.sass +4 -0
  46. data/lib/http_stub/server/views/scenarios.haml +3 -0
  47. data/lib/http_stub/version.rb +1 -1
  48. data/spec/acceptance/activator_spec.rb +81 -0
  49. data/spec/acceptance/configurer_initialization_spec.rb +158 -0
  50. data/spec/acceptance/scenario_spec.rb +91 -0
  51. data/spec/acceptance/stub_control_values_spec.rb +160 -0
  52. data/spec/acceptance/stub_spec.rb +290 -0
  53. data/spec/acceptance/stub_trigger_spec.rb +144 -0
  54. data/spec/lib/http_stub/configurer/{deprecated_dsl_spec.rb → dsl/deprecated_spec.rb} +21 -13
  55. data/spec/lib/http_stub/configurer/{server/dsl_spec.rb → dsl/sanctioned_spec.rb} +74 -97
  56. data/spec/lib/http_stub/configurer/dsl/scenario_activator_spec.rb +62 -0
  57. data/spec/lib/http_stub/configurer/dsl/scenario_builder_spec.rb +146 -0
  58. data/spec/lib/http_stub/configurer/dsl/stub_activator_builder_spec.rb +120 -0
  59. data/spec/lib/http_stub/configurer/dsl/stub_builder_producer_spec.rb +105 -0
  60. data/spec/lib/http_stub/configurer/{request → dsl}/stub_builder_spec.rb +33 -5
  61. data/spec/lib/http_stub/configurer/request/controllable_value_spec.rb +1 -1
  62. data/spec/lib/http_stub/configurer/request/http/factory_spec.rb +46 -5
  63. data/spec/lib/http_stub/configurer/request/omittable_spec.rb +1 -1
  64. data/spec/lib/http_stub/configurer/request/scenario_spec.rb +69 -0
  65. data/spec/lib/http_stub/configurer/request/stub_spec.rb +2 -2
  66. data/spec/lib/http_stub/configurer/server/facade_spec.rb +17 -17
  67. data/spec/lib/http_stub/configurer_spec.rb +1 -1
  68. data/spec/lib/http_stub/server/application_integration_spec.rb +23 -13
  69. data/spec/lib/http_stub/server/application_spec.rb +40 -38
  70. data/spec/lib/http_stub/server/daemon_spec.rb +2 -2
  71. data/spec/lib/http_stub/server/registry_spec.rb +66 -17
  72. data/spec/lib/http_stub/server/{request_parser_spec.rb → request_file_consolidator_spec.rb} +20 -33
  73. data/spec/lib/http_stub/server/response_pipeline_spec.rb +1 -1
  74. data/spec/lib/http_stub/server/scenario/activator_spec.rb +106 -0
  75. data/spec/lib/http_stub/server/scenario/controller_spec.rb +102 -0
  76. data/spec/lib/http_stub/server/scenario/instance_spec.rb +126 -0
  77. data/spec/lib/http_stub/server/scenario/request_parser_spec.rb +59 -0
  78. data/spec/lib/http_stub/server/scenario_spec.rb +24 -0
  79. data/spec/lib/http_stub/server/{stub_controller_spec.rb → stub/controller_spec.rb} +13 -17
  80. data/spec/lib/http_stub/server/{exact_value_matcher_spec.rb → stub/exact_value_matcher_spec.rb} +3 -3
  81. data/spec/lib/http_stub/server/{hash_with_string_value_matchers_spec.rb → stub/hash_with_string_value_matchers_spec.rb} +7 -5
  82. data/spec/lib/http_stub/server/{headers_spec.rb → stub/headers_spec.rb} +2 -2
  83. data/spec/lib/http_stub/server/stub/instance_spec.rb +201 -0
  84. data/spec/lib/http_stub/server/stub/method_spec.rb +95 -0
  85. data/spec/lib/http_stub/server/{omitted_value_matcher_spec.rb → stub/omitted_value_matcher_spec.rb} +3 -3
  86. data/spec/lib/http_stub/server/{regexp_value_matcher_spec.rb → stub/regexp_value_matcher_spec.rb} +3 -3
  87. data/spec/lib/http_stub/server/stub/registry_integration_spec.rb +56 -0
  88. data/spec/lib/http_stub/server/{stub_registry_spec.rb → stub/registry_spec.rb} +27 -14
  89. data/spec/lib/http_stub/server/{request_header_parser_spec.rb → stub/request_header_parser_spec.rb} +6 -6
  90. data/spec/lib/http_stub/server/stub/request_headers_spec.rb +68 -0
  91. data/spec/lib/http_stub/server/{stub_parameters_spec.rb → stub/request_parameters_spec.rb} +19 -17
  92. data/spec/lib/http_stub/server/stub/request_parser_spec.rb +56 -0
  93. data/spec/lib/http_stub/server/{stub_response → stub/response}/base_spec.rb +5 -5
  94. data/spec/lib/http_stub/server/{stub_response → stub/response}/file_spec.rb +3 -3
  95. data/spec/lib/http_stub/server/{stub_response → stub/response}/text_spec.rb +3 -3
  96. data/spec/lib/http_stub/server/{stub_response_spec.rb → stub/response_spec.rb} +8 -8
  97. data/spec/lib/http_stub/server/{string_value_matcher_spec.rb → stub/string_value_matcher_spec.rb} +25 -13
  98. data/spec/lib/http_stub/server/{stub_triggers_spec.rb → stub/triggers_spec.rb} +7 -9
  99. data/spec/lib/http_stub/server/stub/uri_spec.rb +43 -0
  100. data/spec/lib/http_stub/server/stub_spec.rb +10 -185
  101. data/spec/spec_helper.rb +10 -5
  102. data/spec/support/configurer_integration.rb +24 -0
  103. data/spec/support/scenario_fixture.rb +33 -0
  104. data/spec/support/stub_fixture.rb +1 -1
  105. metadata +126 -84
  106. data/lib/http_stub/configurer/deprecated_dsl.rb +0 -57
  107. data/lib/http_stub/configurer/request/stub_activator.rb +0 -26
  108. data/lib/http_stub/configurer/request/stub_activator_builder.rb +0 -25
  109. data/lib/http_stub/server/exact_value_matcher.rb +0 -13
  110. data/lib/http_stub/server/hash_with_string_value_matchers.rb +0 -20
  111. data/lib/http_stub/server/headers.rb +0 -17
  112. data/lib/http_stub/server/omitted_value_matcher.rb +0 -19
  113. data/lib/http_stub/server/regexp_value_matcher.rb +0 -14
  114. data/lib/http_stub/server/request_header_parser.rb +0 -17
  115. data/lib/http_stub/server/request_parser.rb +0 -29
  116. data/lib/http_stub/server/string_value_matcher.rb +0 -29
  117. data/lib/http_stub/server/stub_activator.rb +0 -30
  118. data/lib/http_stub/server/stub_activator_controller.rb +0 -34
  119. data/lib/http_stub/server/stub_controller.rb +0 -28
  120. data/lib/http_stub/server/stub_headers.rb +0 -24
  121. data/lib/http_stub/server/stub_parameters.rb +0 -21
  122. data/lib/http_stub/server/stub_registry.rb +0 -29
  123. data/lib/http_stub/server/stub_response.rb +0 -14
  124. data/lib/http_stub/server/stub_response/base.rb +0 -62
  125. data/lib/http_stub/server/stub_response/file.rb +0 -34
  126. data/lib/http_stub/server/stub_response/text.rb +0 -17
  127. data/lib/http_stub/server/stub_triggers.rb +0 -23
  128. data/lib/http_stub/server/stub_uri.rb +0 -21
  129. data/lib/http_stub/server/views/stub_activators.haml +0 -6
  130. data/spec/lib/http_stub/configurer/request/stub_activator_builder_spec.rb +0 -119
  131. data/spec/lib/http_stub/configurer/request/stub_activator_spec.rb +0 -45
  132. data/spec/lib/http_stub/configurer_integration_spec.rb +0 -837
  133. data/spec/lib/http_stub/server/stub_activator_controller_spec.rb +0 -95
  134. data/spec/lib/http_stub/server/stub_activator_spec.rb +0 -83
  135. data/spec/lib/http_stub/server/stub_headers_spec.rb +0 -68
  136. data/spec/lib/http_stub/server/stub_registry_integration_spec.rb +0 -62
  137. data/spec/lib/http_stub/server/stub_uri_spec.rb +0 -42
@@ -9,11 +9,10 @@ module HttpStub
9
9
 
10
10
  def initialize
11
11
  super()
12
- @stub_registry = HttpStub::Server::StubRegistry.new
13
- @stub_activator_registry = HttpStub::Server::Registry.new("stub_activator")
14
- @stub_controller = HttpStub::Server::StubController.new(@stub_registry)
15
- @stub_activator_controller =
16
- HttpStub::Server::StubActivatorController.new(@stub_activator_registry, @stub_registry)
12
+ @stub_registry = HttpStub::Server::Stub::Registry.new
13
+ @scenario_registry = HttpStub::Server::Registry.new("scenario")
14
+ @stub_controller = HttpStub::Server::Stub::Controller.new(@stub_registry)
15
+ @scenario_controller = HttpStub::Server::Scenario::Controller.new(@scenario_registry, @stub_registry)
17
16
  end
18
17
 
19
18
  private
@@ -71,20 +70,28 @@ module HttpStub
71
70
 
72
71
  # Sample request body:
73
72
  # {
74
- # "activation_uri": "/some/path",
75
- # ... see /stub ...
73
+ # "name": "some_scenario_name",
74
+ # "stubs": [
75
+ # {
76
+ # ... see /stub ...
77
+ # },
78
+ # ],
79
+ # "triggered_scenario_names": [
80
+ # "some_other_scenario_name",
81
+ # ...
82
+ # ]
76
83
  # }
77
- post "/stubs/activators" do
78
- response = @stub_activator_controller.register(request)
84
+ post "/stubs/scenarios" do
85
+ response = @scenario_controller.register(request)
79
86
  @response_pipeline.process(response)
80
87
  end
81
88
 
82
- get "/stubs/activators" do
83
- haml :stub_activators, {}, stub_activators: @stub_activator_registry.all.sort_by(&:activation_uri)
89
+ get "/stubs/scenarios" do
90
+ haml :scenarios, {}, scenarios: @scenario_registry.all.sort_by(&:uri)
84
91
  end
85
92
 
86
- delete "/stubs/activators" do
87
- @stub_activator_controller.clear(request)
93
+ delete "/stubs/scenarios" do
94
+ @scenario_controller.clear(request)
88
95
  halt 200, "OK"
89
96
  end
90
97
 
@@ -106,7 +113,7 @@ module HttpStub
106
113
 
107
114
  def handle_request
108
115
  response = @stub_controller.replay(request)
109
- response = @stub_activator_controller.activate(request) if response.empty?
116
+ response = @scenario_controller.activate(request) if response.empty?
110
117
  response = HttpStub::Server::Response::ERROR if response.empty?
111
118
  @response_pipeline.process(response)
112
119
  end
@@ -13,9 +13,13 @@ module HttpStub
13
13
  request.logger.info "Registered #{@model_name}: #{model}"
14
14
  end
15
15
 
16
- def find_for(request)
17
- request.logger.info "Finding #{@model_name} satisfying: #{request.inspect}"
18
- @models.find { |model| model.satisfies?(request) }
16
+ def concat(models, request)
17
+ models.each { |model| self.add(model, request) }
18
+ end
19
+
20
+ def find(args)
21
+ args[:request].logger.info "Finding #{@model_name} satisfying: #{args[:criteria]}"
22
+ @models.find { |model| model.satisfies?(args[:criteria]) }
19
23
  end
20
24
 
21
25
  def last
@@ -3,9 +3,9 @@ module HttpStub
3
3
 
4
4
  class Response
5
5
 
6
- SUCCESS = HttpStub::Server::StubResponse::Text.new("status" => 200, "body" => "OK").freeze
7
- ERROR = HttpStub::Server::StubResponse::Text.new("status" => 404, "body" => "ERROR").freeze
8
- EMPTY = HttpStub::Server::StubResponse::Text.new.freeze
6
+ SUCCESS = HttpStub::Server::Stub::Response::Text.new("status" => 200, "body" => "OK").freeze
7
+ ERROR = HttpStub::Server::Stub::Response::Text.new("status" => 404, "body" => "ERROR").freeze
8
+ EMPTY = HttpStub::Server::Stub::Response::Text.new.freeze
9
9
 
10
10
  end
11
11
 
@@ -0,0 +1,12 @@
1
+ module HttpStub
2
+ module Server
3
+
4
+ module Scenario
5
+
6
+ def self.create(args)
7
+ HttpStub::Server::Scenario::Instance.new(args)
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,25 @@
1
+ module HttpStub
2
+ module Server
3
+ module Scenario
4
+
5
+ class Activator
6
+
7
+ def initialize(scenario_registry, stub_registry)
8
+ @scenario_registry = scenario_registry
9
+ @stub_registry = stub_registry
10
+ end
11
+
12
+ def activate(scenario, request)
13
+ @stub_registry.concat(scenario.stubs, request)
14
+ scenario.triggered_scenario_names.each do |triggered_scenario_name|
15
+ scenario_to_activate = @scenario_registry.find(criteria: triggered_scenario_name, request: request)
16
+ raise "Scenario not found with name '#{triggered_scenario_name}'" unless scenario_to_activate
17
+ activate(scenario_to_activate, request)
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,36 @@
1
+ module HttpStub
2
+ module Server
3
+ module Scenario
4
+
5
+ class Controller
6
+
7
+ def initialize(scenario_registry, stub_registry)
8
+ @scenario_registry = scenario_registry
9
+ @scenario_activator = HttpStub::Server::Scenario::Activator.new(scenario_registry, stub_registry)
10
+ end
11
+
12
+ def register(request)
13
+ scenario = HttpStub::Server::Scenario.create(HttpStub::Server::Scenario::RequestParser.parse(request))
14
+ @scenario_registry.add(scenario, request)
15
+ HttpStub::Server::Response::SUCCESS
16
+ end
17
+
18
+ def activate(request)
19
+ scenario = @scenario_registry.find(criteria: request.path_info.gsub(/^\//, ""), request: request)
20
+ if scenario
21
+ @scenario_activator.activate(scenario, request)
22
+ HttpStub::Server::Response::SUCCESS
23
+ else
24
+ HttpStub::Server::Response::EMPTY
25
+ end
26
+ end
27
+
28
+ def clear(request)
29
+ @scenario_registry.clear(request)
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,36 @@
1
+ module HttpStub
2
+ module Server
3
+ module Scenario
4
+
5
+ class Instance
6
+
7
+ attr_reader :name, :stubs, :triggered_scenario_names
8
+
9
+ def initialize(args)
10
+ @args = args
11
+ @name = @args["name"]
12
+ @stubs = args["stubs"].map { |stub_args| HttpStub::Server::Stub.create(stub_args) }
13
+ @triggered_scenario_names = @args["triggered_scenario_names"]
14
+ end
15
+
16
+ def satisfies?(name)
17
+ @name == name
18
+ end
19
+
20
+ def uri
21
+ "/#{@name}"
22
+ end
23
+
24
+ def triggered_scenarios
25
+ @triggered_scenario_names.reduce([]) { |result, name| result << [ name, "/#{name}" ] }
26
+ end
27
+
28
+ def to_s
29
+ @args.to_s
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,19 @@
1
+ module HttpStub
2
+ module Server
3
+ module Scenario
4
+
5
+ class RequestParser
6
+
7
+ def self.parse(request)
8
+ JSON.parse(request.params["payload"]).tap do |payload|
9
+ payload["stubs"].each do |stub_payload|
10
+ HttpStub::Server::Stub::PayloadFileConsolidator.consolidate!(stub_payload, request)
11
+ end
12
+ end
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -1,32 +1,12 @@
1
1
  module HttpStub
2
2
  module Server
3
3
 
4
- class Stub
4
+ module Stub
5
5
 
6
- attr_reader :method, :uri, :headers, :parameters, :response, :triggers
7
-
8
- def initialize(args)
9
- @method = args["method"]
10
- @uri = HttpStub::Server::StubUri.new(args["uri"])
11
- @headers = HttpStub::Server::StubHeaders.new(args["headers"])
12
- @parameters = HttpStub::Server::StubParameters.new(args["parameters"])
13
- @response = HttpStub::Server::StubResponse.create(args["response"])
14
- @triggers = HttpStub::Server::StubTriggers.new(args["triggers"])
15
- @description = args.to_s
16
- end
17
-
18
- def satisfies?(request)
19
- @uri.match?(request) &&
20
- @method.downcase == request.request_method.downcase &&
21
- @headers.match?(request) &&
22
- @parameters.match?(request)
23
- end
24
-
25
- def to_s
26
- @description
6
+ def self.create(args)
7
+ HttpStub::Server::Stub::Instance.new(args)
27
8
  end
28
9
 
29
10
  end
30
-
31
11
  end
32
12
  end
@@ -0,0 +1,30 @@
1
+ module HttpStub
2
+ module Server
3
+ module Stub
4
+
5
+ class Controller
6
+
7
+ def initialize(registry)
8
+ @registry = registry
9
+ end
10
+
11
+ def register(request)
12
+ stub = HttpStub::Server::Stub.create(HttpStub::Server::Stub::RequestParser.parse(request))
13
+ @registry.add(stub, request)
14
+ HttpStub::Server::Response::SUCCESS
15
+ end
16
+
17
+ def replay(request)
18
+ stub = @registry.find_for(request)
19
+ stub ? stub.response : HttpStub::Server::Response::EMPTY
20
+ end
21
+
22
+ def clear(request)
23
+ @registry.clear(request)
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,15 @@
1
+ module HttpStub
2
+ module Server
3
+ module Stub
4
+
5
+ class ExactValueMatcher
6
+
7
+ def self.match?(stub_value, actual_value)
8
+ stub_value == actual_value
9
+ end
10
+
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ module HttpStub
2
+ module Server
3
+ module Stub
4
+
5
+ class HashWithStringValueMatchers < Hash
6
+
7
+ def initialize(stub_hash)
8
+ stub_hash.each_pair { |key, value| self[key] = HttpStub::Server::Stub::StringValueMatcher.new(value) }
9
+ end
10
+
11
+ def match?(actual_hash)
12
+ !(self.find do |key_and_value_matcher|
13
+ key, value_matcher = key_and_value_matcher
14
+ !value_matcher.match?(actual_hash[key])
15
+ end)
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ module HttpStub
2
+ module Server
3
+ module Stub
4
+
5
+ class Headers < Hash
6
+
7
+ def initialize(headers)
8
+ self.merge!(headers || {})
9
+ end
10
+
11
+ def to_s
12
+ self.map { |key_and_value| key_and_value.map(&:to_s).join(":") }.join(", ")
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,31 @@
1
+ module HttpStub
2
+ module Server
3
+ module Stub
4
+
5
+ class Instance
6
+
7
+ attr_reader :method, :uri, :headers, :parameters, :response, :triggers
8
+
9
+ def initialize(args)
10
+ @method = HttpStub::Server::Stub::Method.new(args["method"])
11
+ @uri = HttpStub::Server::Stub::Uri.new(args["uri"])
12
+ @headers = HttpStub::Server::Stub::RequestHeaders.new(args["headers"])
13
+ @parameters = HttpStub::Server::Stub::RequestParameters.new(args["parameters"])
14
+ @response = HttpStub::Server::Stub::Response.create(args["response"])
15
+ @triggers = HttpStub::Server::Stub::Triggers.new(args["triggers"])
16
+ @description = args.to_s
17
+ end
18
+
19
+ def satisfies?(request)
20
+ [ @uri, @method, @headers, @parameters ].all? { |matcher| matcher.match?(request) }
21
+ end
22
+
23
+ def to_s
24
+ @description
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,23 @@
1
+ module HttpStub
2
+ module Server
3
+ module Stub
4
+
5
+ class Method
6
+
7
+ def initialize(method)
8
+ @method = method
9
+ end
10
+
11
+ def match?(request)
12
+ @method.blank? || @method.downcase == request.request_method.downcase
13
+ end
14
+
15
+ def to_s
16
+ @method || ""
17
+ end
18
+
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ module HttpStub
2
+ module Server
3
+ module Stub
4
+
5
+ class OmittedValueMatcher
6
+
7
+ private
8
+
9
+ OMITTED_CONTROL_VALUE = "control:omitted".freeze
10
+
11
+ public
12
+
13
+ def self.match?(stub_value, actual_value)
14
+ stub_value == OMITTED_CONTROL_VALUE && actual_value.nil?
15
+ end
16
+
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ module HttpStub
2
+ module Server
3
+ module Stub
4
+
5
+ class PayloadFileConsolidator
6
+
7
+ def self.consolidate!(payload, request)
8
+ response_file = request.params["response_file_#{payload["id"]}"]
9
+ payload["response"]["body"] = response_file if response_file
10
+ payload["triggers"].each { |trigger_payload| consolidate!(trigger_payload, request) } if payload["triggers"]
11
+ payload
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+ end
18
+ end