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
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
shared_context "stub payload builder arguments" do
|
2
|
+
|
3
|
+
let(:uri) { "/some/uri" }
|
4
|
+
let(:stub_method) { "Some Method" }
|
5
|
+
let(:request_headers) { { request_header_name: "value" } }
|
6
|
+
let(:request_parameters) { { parameter_name: "value" } }
|
7
|
+
let(:request_options) do
|
8
|
+
{
|
9
|
+
method: stub_method,
|
10
|
+
headers: request_headers,
|
11
|
+
parameters: request_parameters
|
12
|
+
}
|
13
|
+
end
|
14
|
+
let(:response_status) { 500 }
|
15
|
+
let(:response_headers) { { response_header_name: "value" } }
|
16
|
+
let(:response_body) { "Some body" }
|
17
|
+
let(:response_delay_in_seconds) { 7 }
|
18
|
+
let(:response_options) do
|
19
|
+
{
|
20
|
+
status: response_status,
|
21
|
+
headers: response_headers,
|
22
|
+
body: response_body,
|
23
|
+
delay_in_seconds: response_delay_in_seconds
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
shared_context "server integration" do
|
2
2
|
|
3
|
-
before(:
|
3
|
+
before(:context) do
|
4
4
|
@pid = Process.spawn("rake example_server:start:foreground --trace")
|
5
5
|
::Wait.until!("http stub server started") { Net::HTTP.get_response(server_host, "/", server_port) }
|
6
6
|
end
|
7
7
|
|
8
|
-
after(:
|
8
|
+
after(:context) { Process.kill(9, @pid) }
|
9
9
|
|
10
10
|
def server_host
|
11
11
|
"localhost"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_stub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ueckerman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '10.
|
20
|
+
version: '10.3'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '10.
|
27
|
+
version: '10.3'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: sinatra
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,14 +73,14 @@ dependencies:
|
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '3.
|
76
|
+
version: '3.4'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '3.
|
83
|
+
version: '3.4'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: http_server_manager
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,62 +95,76 @@ dependencies:
|
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0.4'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: activesupport
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '4.0'
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '4.0'
|
98
112
|
- !ruby/object:Gem::Dependency
|
99
113
|
name: travis-lint
|
100
114
|
requirement: !ruby/object:Gem::Requirement
|
101
115
|
requirements:
|
102
116
|
- - "~>"
|
103
117
|
- !ruby/object:Gem::Version
|
104
|
-
version: '
|
118
|
+
version: '2.0'
|
105
119
|
type: :development
|
106
120
|
prerelease: false
|
107
121
|
version_requirements: !ruby/object:Gem::Requirement
|
108
122
|
requirements:
|
109
123
|
- - "~>"
|
110
124
|
- !ruby/object:Gem::Version
|
111
|
-
version: '
|
125
|
+
version: '2.0'
|
112
126
|
- !ruby/object:Gem::Dependency
|
113
127
|
name: metric_fu
|
114
128
|
requirement: !ruby/object:Gem::Requirement
|
115
129
|
requirements:
|
116
130
|
- - "~>"
|
117
131
|
- !ruby/object:Gem::Version
|
118
|
-
version: '4.
|
132
|
+
version: '4.11'
|
119
133
|
type: :development
|
120
134
|
prerelease: false
|
121
135
|
version_requirements: !ruby/object:Gem::Requirement
|
122
136
|
requirements:
|
123
137
|
- - "~>"
|
124
138
|
- !ruby/object:Gem::Version
|
125
|
-
version: '4.
|
139
|
+
version: '4.11'
|
126
140
|
- !ruby/object:Gem::Dependency
|
127
141
|
name: rspec
|
128
142
|
requirement: !ruby/object:Gem::Requirement
|
129
143
|
requirements:
|
130
144
|
- - "~>"
|
131
145
|
- !ruby/object:Gem::Version
|
132
|
-
version: '
|
146
|
+
version: '3.1'
|
133
147
|
type: :development
|
134
148
|
prerelease: false
|
135
149
|
version_requirements: !ruby/object:Gem::Requirement
|
136
150
|
requirements:
|
137
151
|
- - "~>"
|
138
152
|
- !ruby/object:Gem::Version
|
139
|
-
version: '
|
153
|
+
version: '3.1'
|
140
154
|
- !ruby/object:Gem::Dependency
|
141
155
|
name: simplecov
|
142
156
|
requirement: !ruby/object:Gem::Requirement
|
143
157
|
requirements:
|
144
158
|
- - "~>"
|
145
159
|
- !ruby/object:Gem::Version
|
146
|
-
version: '0.
|
160
|
+
version: '0.9'
|
147
161
|
type: :development
|
148
162
|
prerelease: false
|
149
163
|
version_requirements: !ruby/object:Gem::Requirement
|
150
164
|
requirements:
|
151
165
|
- - "~>"
|
152
166
|
- !ruby/object:Gem::Version
|
153
|
-
version: '0.
|
167
|
+
version: '0.9'
|
154
168
|
- !ruby/object:Gem::Dependency
|
155
169
|
name: rack-test
|
156
170
|
requirement: !ruby/object:Gem::Requirement
|
@@ -185,14 +199,14 @@ dependencies:
|
|
185
199
|
requirements:
|
186
200
|
- - "~>"
|
187
201
|
- !ruby/object:Gem::Version
|
188
|
-
version: '0.
|
202
|
+
version: '0.13'
|
189
203
|
type: :development
|
190
204
|
prerelease: false
|
191
205
|
version_requirements: !ruby/object:Gem::Requirement
|
192
206
|
requirements:
|
193
207
|
- - "~>"
|
194
208
|
- !ruby/object:Gem::Version
|
195
|
-
version: '0.
|
209
|
+
version: '0.13'
|
196
210
|
- !ruby/object:Gem::Dependency
|
197
211
|
name: wait_until
|
198
212
|
requirement: !ruby/object:Gem::Requirement
|
@@ -229,15 +243,20 @@ extra_rdoc_files: []
|
|
229
243
|
files:
|
230
244
|
- "./lib/http_stub.rb"
|
231
245
|
- "./lib/http_stub/configurer.rb"
|
232
|
-
- "./lib/http_stub/configurer/
|
233
|
-
- "./lib/http_stub/configurer/command_processor.rb"
|
234
|
-
- "./lib/http_stub/configurer/impatient_command_chain.rb"
|
235
|
-
- "./lib/http_stub/configurer/patient_command_chain.rb"
|
246
|
+
- "./lib/http_stub/configurer/deprecated_dsl.rb"
|
236
247
|
- "./lib/http_stub/configurer/request/controllable_value.rb"
|
237
248
|
- "./lib/http_stub/configurer/request/omittable.rb"
|
238
249
|
- "./lib/http_stub/configurer/request/regexpable.rb"
|
239
250
|
- "./lib/http_stub/configurer/request/stub.rb"
|
240
251
|
- "./lib/http_stub/configurer/request/stub_activator.rb"
|
252
|
+
- "./lib/http_stub/configurer/request/stub_activator_payload_builder.rb"
|
253
|
+
- "./lib/http_stub/configurer/request/stub_payload_builder.rb"
|
254
|
+
- "./lib/http_stub/configurer/server/buffered_command_processor.rb"
|
255
|
+
- "./lib/http_stub/configurer/server/command.rb"
|
256
|
+
- "./lib/http_stub/configurer/server/command_processor.rb"
|
257
|
+
- "./lib/http_stub/configurer/server/dsl.rb"
|
258
|
+
- "./lib/http_stub/configurer/server/facade.rb"
|
259
|
+
- "./lib/http_stub/configurer/server/request_processor.rb"
|
241
260
|
- "./lib/http_stub/controllers/stub_activator_controller.rb"
|
242
261
|
- "./lib/http_stub/controllers/stub_controller.rb"
|
243
262
|
- "./lib/http_stub/hash_extensions.rb"
|
@@ -255,6 +274,8 @@ files:
|
|
255
274
|
- "./lib/http_stub/models/stub_activator.rb"
|
256
275
|
- "./lib/http_stub/models/stub_headers.rb"
|
257
276
|
- "./lib/http_stub/models/stub_parameters.rb"
|
277
|
+
- "./lib/http_stub/models/stub_registry.rb"
|
278
|
+
- "./lib/http_stub/models/stub_triggers.rb"
|
258
279
|
- "./lib/http_stub/models/stub_uri.rb"
|
259
280
|
- "./lib/http_stub/rake/server_daemon_tasks.rb"
|
260
281
|
- "./lib/http_stub/rake/server_tasks.rb"
|
@@ -268,15 +289,20 @@ files:
|
|
268
289
|
- "./lib/http_stub/views/stub_activators.haml"
|
269
290
|
- "./lib/http_stub/views/stubs.haml"
|
270
291
|
- "./spec/curl_samples.txt"
|
271
|
-
- "./spec/lib/http_stub/configurer/
|
272
|
-
- "./spec/lib/http_stub/configurer/command_spec.rb"
|
273
|
-
- "./spec/lib/http_stub/configurer/impatient_command_chain_spec.rb"
|
274
|
-
- "./spec/lib/http_stub/configurer/patient_command_chain_spec.rb"
|
292
|
+
- "./spec/lib/http_stub/configurer/deprecated_dsl_spec.rb"
|
275
293
|
- "./spec/lib/http_stub/configurer/request/controllable_value_spec.rb"
|
276
294
|
- "./spec/lib/http_stub/configurer/request/omittable_spec.rb"
|
277
295
|
- "./spec/lib/http_stub/configurer/request/regexpable_spec.rb"
|
296
|
+
- "./spec/lib/http_stub/configurer/request/stub_activator_payload_builder_spec.rb"
|
278
297
|
- "./spec/lib/http_stub/configurer/request/stub_activator_spec.rb"
|
298
|
+
- "./spec/lib/http_stub/configurer/request/stub_payload_builder_spec.rb"
|
279
299
|
- "./spec/lib/http_stub/configurer/request/stub_spec.rb"
|
300
|
+
- "./spec/lib/http_stub/configurer/server/buffered_command_processor_spec.rb"
|
301
|
+
- "./spec/lib/http_stub/configurer/server/command_processor_integration_spec.rb"
|
302
|
+
- "./spec/lib/http_stub/configurer/server/command_spec.rb"
|
303
|
+
- "./spec/lib/http_stub/configurer/server/dsl_spec.rb"
|
304
|
+
- "./spec/lib/http_stub/configurer/server/facade_spec.rb"
|
305
|
+
- "./spec/lib/http_stub/configurer/server/request_processor_spec.rb"
|
280
306
|
- "./spec/lib/http_stub/configurer_integration_spec.rb"
|
281
307
|
- "./spec/lib/http_stub/configurer_spec.rb"
|
282
308
|
- "./spec/lib/http_stub/controllers/stub_activator_controller_spec.rb"
|
@@ -295,7 +321,10 @@ files:
|
|
295
321
|
- "./spec/lib/http_stub/models/stub_activator_spec.rb"
|
296
322
|
- "./spec/lib/http_stub/models/stub_headers_spec.rb"
|
297
323
|
- "./spec/lib/http_stub/models/stub_parameters_spec.rb"
|
324
|
+
- "./spec/lib/http_stub/models/stub_registry_integration_spec.rb"
|
325
|
+
- "./spec/lib/http_stub/models/stub_registry_spec.rb"
|
298
326
|
- "./spec/lib/http_stub/models/stub_spec.rb"
|
327
|
+
- "./spec/lib/http_stub/models/stub_triggers_spec.rb"
|
299
328
|
- "./spec/lib/http_stub/models/stub_uri_spec.rb"
|
300
329
|
- "./spec/lib/http_stub/rake/server_daemon_tasks_smoke_spec.rb"
|
301
330
|
- "./spec/lib/http_stub/rake/server_tasks_smoke_spec.rb"
|
@@ -305,6 +334,7 @@ files:
|
|
305
334
|
- "./spec/lib/http_stub/server_integration_spec.rb"
|
306
335
|
- "./spec/lib/http_stub/server_spec.rb"
|
307
336
|
- "./spec/spec_helper.rb"
|
337
|
+
- "./spec/support/http_stub/configurer/request/stub_payload_builder_shared_context.rb"
|
308
338
|
- "./spec/support/server_integration.rb"
|
309
339
|
homepage: http://github.com/MYOB-Technology/http_stub
|
310
340
|
licenses:
|
@@ -321,9 +351,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
321
351
|
version: 1.9.3
|
322
352
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
323
353
|
requirements:
|
324
|
-
- - "
|
354
|
+
- - ">"
|
325
355
|
- !ruby/object:Gem::Version
|
326
|
-
version:
|
356
|
+
version: 1.3.1
|
327
357
|
requirements: []
|
328
358
|
rubyforge_project: http_stub
|
329
359
|
rubygems_version: 2.2.2
|
@@ -332,15 +362,20 @@ specification_version: 4
|
|
332
362
|
summary: A HTTP Server replaying configured stub responses.
|
333
363
|
test_files:
|
334
364
|
- "./spec/curl_samples.txt"
|
335
|
-
- "./spec/lib/http_stub/configurer/
|
336
|
-
- "./spec/lib/http_stub/configurer/command_spec.rb"
|
337
|
-
- "./spec/lib/http_stub/configurer/impatient_command_chain_spec.rb"
|
338
|
-
- "./spec/lib/http_stub/configurer/patient_command_chain_spec.rb"
|
365
|
+
- "./spec/lib/http_stub/configurer/deprecated_dsl_spec.rb"
|
339
366
|
- "./spec/lib/http_stub/configurer/request/controllable_value_spec.rb"
|
340
367
|
- "./spec/lib/http_stub/configurer/request/omittable_spec.rb"
|
341
368
|
- "./spec/lib/http_stub/configurer/request/regexpable_spec.rb"
|
369
|
+
- "./spec/lib/http_stub/configurer/request/stub_activator_payload_builder_spec.rb"
|
342
370
|
- "./spec/lib/http_stub/configurer/request/stub_activator_spec.rb"
|
371
|
+
- "./spec/lib/http_stub/configurer/request/stub_payload_builder_spec.rb"
|
343
372
|
- "./spec/lib/http_stub/configurer/request/stub_spec.rb"
|
373
|
+
- "./spec/lib/http_stub/configurer/server/buffered_command_processor_spec.rb"
|
374
|
+
- "./spec/lib/http_stub/configurer/server/command_processor_integration_spec.rb"
|
375
|
+
- "./spec/lib/http_stub/configurer/server/command_spec.rb"
|
376
|
+
- "./spec/lib/http_stub/configurer/server/dsl_spec.rb"
|
377
|
+
- "./spec/lib/http_stub/configurer/server/facade_spec.rb"
|
378
|
+
- "./spec/lib/http_stub/configurer/server/request_processor_spec.rb"
|
344
379
|
- "./spec/lib/http_stub/configurer_integration_spec.rb"
|
345
380
|
- "./spec/lib/http_stub/configurer_spec.rb"
|
346
381
|
- "./spec/lib/http_stub/controllers/stub_activator_controller_spec.rb"
|
@@ -359,7 +394,10 @@ test_files:
|
|
359
394
|
- "./spec/lib/http_stub/models/stub_activator_spec.rb"
|
360
395
|
- "./spec/lib/http_stub/models/stub_headers_spec.rb"
|
361
396
|
- "./spec/lib/http_stub/models/stub_parameters_spec.rb"
|
397
|
+
- "./spec/lib/http_stub/models/stub_registry_integration_spec.rb"
|
398
|
+
- "./spec/lib/http_stub/models/stub_registry_spec.rb"
|
362
399
|
- "./spec/lib/http_stub/models/stub_spec.rb"
|
400
|
+
- "./spec/lib/http_stub/models/stub_triggers_spec.rb"
|
363
401
|
- "./spec/lib/http_stub/models/stub_uri_spec.rb"
|
364
402
|
- "./spec/lib/http_stub/rake/server_daemon_tasks_smoke_spec.rb"
|
365
403
|
- "./spec/lib/http_stub/rake/server_tasks_smoke_spec.rb"
|
@@ -369,4 +407,5 @@ test_files:
|
|
369
407
|
- "./spec/lib/http_stub/server_integration_spec.rb"
|
370
408
|
- "./spec/lib/http_stub/server_spec.rb"
|
371
409
|
- "./spec/spec_helper.rb"
|
410
|
+
- "./spec/support/http_stub/configurer/request/stub_payload_builder_shared_context.rb"
|
372
411
|
- "./spec/support/server_integration.rb"
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module HttpStub
|
2
|
-
module Configurer
|
3
|
-
|
4
|
-
class Command
|
5
|
-
|
6
|
-
attr_reader :request, :description
|
7
|
-
|
8
|
-
def initialize(args)
|
9
|
-
@processor = args[:processor]
|
10
|
-
@request = args[:request]
|
11
|
-
@description = args[:description]
|
12
|
-
@resetable_flag = !!args[:resetable]
|
13
|
-
end
|
14
|
-
|
15
|
-
def execute
|
16
|
-
@processor.process(self)
|
17
|
-
end
|
18
|
-
|
19
|
-
def resetable?
|
20
|
-
@resetable_flag
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module HttpStub
|
2
|
-
module Configurer
|
3
|
-
|
4
|
-
class CommandProcessor
|
5
|
-
|
6
|
-
def initialize(configurer)
|
7
|
-
@configurer = configurer
|
8
|
-
end
|
9
|
-
|
10
|
-
def process(command)
|
11
|
-
begin
|
12
|
-
response = Net::HTTP.start(host, port) { |http| http.request(command.request) }
|
13
|
-
raise "#{error_message_prefix(command)}: #{response.code} #{response.message}" unless response.code == "200"
|
14
|
-
rescue Exception => exc
|
15
|
-
raise "#{error_message_prefix(command)}: #{exc}"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def host
|
22
|
-
@configurer.get_host
|
23
|
-
end
|
24
|
-
|
25
|
-
def port
|
26
|
-
@configurer.get_port
|
27
|
-
end
|
28
|
-
|
29
|
-
def error_message_prefix(command)
|
30
|
-
"Error occurred #{command.description} whilst configuring #{@configurer.get_base_uri}: "
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module HttpStub
|
2
|
-
module Configurer
|
3
|
-
|
4
|
-
class PatientCommandChain
|
5
|
-
|
6
|
-
def initialize(commands=[])
|
7
|
-
@commands = commands
|
8
|
-
end
|
9
|
-
|
10
|
-
def <<(command)
|
11
|
-
@commands << command
|
12
|
-
end
|
13
|
-
|
14
|
-
def execute
|
15
|
-
@commands.each(&:execute)
|
16
|
-
end
|
17
|
-
|
18
|
-
def filter(&block)
|
19
|
-
HttpStub::Configurer::PatientCommandChain.new(@commands.select(&block))
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
describe HttpStub::Configurer::CommandProcessor do
|
2
|
-
|
3
|
-
let(:command) { HttpStub::Configurer::Command.new(request: request, description: "performing an operation") }
|
4
|
-
let(:server_base_uri) { "http://localhost:8001" }
|
5
|
-
let(:configurer) do
|
6
|
-
double(HttpStub::Configurer, get_base_uri: server_base_uri, get_host: "localhost", get_port: 8001)
|
7
|
-
end
|
8
|
-
|
9
|
-
let(:command_processor) { HttpStub::Configurer::CommandProcessor.new(configurer) }
|
10
|
-
|
11
|
-
context "when the server is running" do
|
12
|
-
|
13
|
-
include_context "server integration"
|
14
|
-
|
15
|
-
describe "#process" do
|
16
|
-
|
17
|
-
describe "when the server responds with a 200 response" do
|
18
|
-
|
19
|
-
let(:request) { Net::HTTP::Get.new("/stubs") }
|
20
|
-
|
21
|
-
it "should execute without error" do
|
22
|
-
lambda { command_processor.process(command) }.should_not raise_error
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "when the server responds with a non-200 response" do
|
28
|
-
|
29
|
-
let(:request) { Net::HTTP::Get.new("/causes_error") }
|
30
|
-
|
31
|
-
it "should raise an exception that includes the server base URI" do
|
32
|
-
lambda { command_processor.process(command) }.should raise_error(/#{server_base_uri}/)
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should raise an exception that includes the commands description" do
|
36
|
-
lambda { command_processor.process(command) }.should raise_error(/performing an operation/)
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
context "when the server is unavailable" do
|
46
|
-
|
47
|
-
let(:request) { Net::HTTP::Get.new("/does/not/exist") }
|
48
|
-
|
49
|
-
describe "#process" do
|
50
|
-
|
51
|
-
it "should raise an exception that includes the server base URI" do
|
52
|
-
lambda { command_processor.process(command) }.should raise_error(/#{server_base_uri}/)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should raise an exception that includes the commands description" do
|
56
|
-
lambda { command_processor.process(command) }.should raise_error(/performing an operation/)
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|