http_stub 0.14.2 → 0.15.0
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/configurer/request/http/basic.rb +21 -0
- data/lib/http_stub/configurer/request/http/factory.rb +43 -0
- data/lib/http_stub/configurer/request/http/multipart.rb +33 -0
- data/lib/http_stub/configurer/request/stub.rb +24 -8
- data/lib/http_stub/configurer/request/stub_activator.rb +12 -8
- data/lib/http_stub/configurer/request/{stub_activator_payload_builder.rb → stub_activator_builder.rb} +4 -4
- data/lib/http_stub/configurer/request/stub_builder.rb +34 -0
- data/lib/http_stub/configurer/request/stub_response.rb +40 -0
- data/lib/http_stub/configurer/request/stub_response_file.rb +20 -0
- data/lib/http_stub/configurer/server/command.rb +5 -1
- data/lib/http_stub/configurer/server/command_processor.rb +1 -1
- data/lib/http_stub/configurer/server/dsl.rb +4 -4
- data/lib/http_stub/configurer/server/facade.rb +25 -11
- data/lib/http_stub/extensions/core/hash.rb +26 -0
- data/lib/http_stub/rake/server_daemon_tasks.rb +1 -1
- data/lib/http_stub/rake/server_tasks.rb +1 -1
- data/lib/http_stub/rake/task_generators.rb +3 -3
- data/lib/http_stub/server/application.rb +117 -0
- data/lib/http_stub/server/daemon.rb +39 -0
- data/lib/http_stub/{models → server}/exact_value_matcher.rb +1 -1
- data/lib/http_stub/{models → server}/hash_with_string_value_matchers.rb +2 -2
- data/lib/http_stub/{models → server}/headers.rb +1 -1
- data/lib/http_stub/{models → server}/omitted_value_matcher.rb +1 -1
- data/lib/http_stub/{models → server}/regexp_value_matcher.rb +1 -1
- data/lib/http_stub/{models → server}/registry.rb +10 -3
- data/lib/http_stub/{models → server}/request_header_parser.rb +1 -1
- data/lib/http_stub/server/response.rb +13 -0
- data/lib/http_stub/server/response_pipeline.rb +18 -0
- data/lib/http_stub/{models → server}/string_value_matcher.rb +4 -4
- data/lib/http_stub/server/stub.rb +37 -0
- data/lib/http_stub/{models → server}/stub_activator.rb +10 -2
- data/lib/http_stub/{controllers → server}/stub_activator_controller.rb +5 -5
- data/lib/http_stub/{controllers → server}/stub_controller.rb +4 -4
- data/lib/http_stub/server/stub_factory.rb +30 -0
- data/lib/http_stub/{models → server}/stub_headers.rb +4 -4
- data/lib/http_stub/{models → server}/stub_parameters.rb +2 -2
- data/lib/http_stub/{models → server}/stub_registry.rb +4 -4
- data/lib/http_stub/server/stub_response/base.rb +62 -0
- data/lib/http_stub/server/stub_response/file.rb +48 -0
- data/lib/http_stub/server/stub_response/text.rb +17 -0
- data/lib/http_stub/server/stub_response.rb +14 -0
- data/lib/http_stub/{models → server}/stub_triggers.rb +6 -2
- data/lib/http_stub/{models → server}/stub_uri.rb +2 -2
- data/lib/http_stub/{views → server/views}/_stub.haml +0 -0
- data/lib/http_stub/{views → server/views}/application.sass +0 -0
- data/lib/http_stub/{views → server/views}/layout.haml +0 -0
- data/lib/http_stub/{views → server/views}/stub_activators.haml +0 -0
- data/lib/http_stub/{views → server/views}/stubs.haml +0 -0
- data/lib/http_stub/version.rb +1 -1
- data/lib/http_stub.rb +41 -24
- data/spec/lib/http_stub/configurer/deprecated_dsl_spec.rb +2 -2
- data/spec/lib/http_stub/configurer/request/http/basic_spec.rb +15 -0
- data/spec/lib/http_stub/configurer/request/http/factory_spec.rb +148 -0
- data/spec/lib/http_stub/configurer/request/http/multipart_spec.rb +74 -0
- data/spec/lib/http_stub/configurer/request/stub_activator_builder_spec.rb +119 -0
- data/spec/lib/http_stub/configurer/request/stub_activator_spec.rb +24 -22
- data/spec/lib/http_stub/configurer/request/stub_builder_spec.rb +154 -0
- data/spec/lib/http_stub/configurer/request/stub_response_spec.rb +136 -0
- data/spec/lib/http_stub/configurer/request/stub_spec.rb +238 -17
- data/spec/lib/http_stub/configurer/server/command_processor_integration_spec.rb +7 -3
- data/spec/lib/http_stub/configurer/server/command_spec.rb +7 -6
- data/spec/lib/http_stub/configurer/server/dsl_spec.rb +58 -94
- data/spec/lib/http_stub/configurer/server/facade_spec.rb +56 -41
- data/spec/lib/http_stub/configurer_integration_spec.rb +180 -81
- data/spec/lib/http_stub/{hash_extensions_spec.rb → extensions/core/hash_spec.rb} +1 -1
- data/spec/lib/http_stub/rake/server_daemon_tasks_smoke_spec.rb +1 -1
- data/spec/lib/http_stub/{server_integration_spec.rb → server/application_integration_spec.rb} +1 -1
- data/spec/lib/http_stub/server/application_spec.rb +205 -0
- data/spec/lib/http_stub/server/daemon_integration_spec.rb +7 -0
- data/spec/lib/http_stub/{server_daemon_spec.rb → server/daemon_spec.rb} +4 -4
- data/spec/lib/http_stub/{models → server}/exact_value_matcher_spec.rb +2 -2
- data/spec/lib/http_stub/{models → server}/hash_with_string_value_matchers_spec.rb +5 -5
- data/spec/lib/http_stub/{models → server}/headers_spec.rb +2 -2
- data/spec/lib/http_stub/{models → server}/omitted_value_matcher_spec.rb +2 -2
- data/spec/lib/http_stub/{models → server}/regexp_value_matcher_spec.rb +2 -2
- data/spec/lib/http_stub/{models → server}/registry_spec.rb +52 -55
- data/spec/lib/http_stub/{models → server}/request_header_parser_spec.rb +4 -4
- data/spec/lib/http_stub/server/response_pipeline_spec.rb +29 -0
- data/spec/lib/http_stub/server/response_spec.rb +41 -0
- data/spec/lib/http_stub/{models → server}/string_value_matcher_spec.rb +11 -11
- data/spec/lib/http_stub/server/stub_activator_controller_spec.rb +85 -0
- data/spec/lib/http_stub/server/stub_activator_spec.rb +124 -0
- data/spec/lib/http_stub/server/stub_controller_spec.rb +74 -0
- data/spec/lib/http_stub/server/stub_factory_spec.rb +117 -0
- data/spec/lib/http_stub/{models → server}/stub_headers_spec.rb +9 -9
- data/spec/lib/http_stub/{models → server}/stub_parameters_spec.rb +6 -6
- data/spec/lib/http_stub/{models → server}/stub_registry_integration_spec.rb +3 -3
- data/spec/lib/http_stub/{models → server}/stub_registry_spec.rb +15 -35
- data/spec/lib/http_stub/server/stub_response/base_spec.rb +225 -0
- data/spec/lib/http_stub/server/stub_response/file_spec.rb +140 -0
- data/spec/lib/http_stub/server/stub_response/text_spec.rb +103 -0
- data/spec/lib/http_stub/server/stub_response_spec.rb +49 -0
- data/spec/lib/http_stub/{models → server}/stub_spec.rb +34 -18
- data/spec/lib/http_stub/{models → server}/stub_triggers_spec.rb +26 -16
- data/spec/lib/http_stub/{models → server}/stub_uri_spec.rb +5 -5
- data/spec/resources/sample.pdf +0 -0
- data/spec/resources/sample.txt +1 -0
- data/spec/spec_helper.rb +13 -4
- data/spec/support/stub_fixture.rb +106 -0
- metadata +148 -102
- data/lib/http_stub/configurer/request/stub_payload_builder.rb +0 -46
- data/lib/http_stub/hash_extensions.rb +0 -22
- data/lib/http_stub/models/request_pipeline.rb +0 -13
- data/lib/http_stub/models/response.rb +0 -43
- data/lib/http_stub/models/stub.rb +0 -35
- data/lib/http_stub/server.rb +0 -114
- data/lib/http_stub/server_daemon.rb +0 -36
- data/spec/lib/http_stub/configurer/request/stub_activator_payload_builder_spec.rb +0 -103
- data/spec/lib/http_stub/configurer/request/stub_payload_builder_spec.rb +0 -304
- data/spec/lib/http_stub/controllers/stub_activator_controller_spec.rb +0 -94
- data/spec/lib/http_stub/controllers/stub_controller_spec.rb +0 -83
- data/spec/lib/http_stub/models/request_pipeline_spec.rb +0 -17
- data/spec/lib/http_stub/models/response_spec.rb +0 -206
- data/spec/lib/http_stub/models/stub_activator_spec.rb +0 -76
- data/spec/lib/http_stub/server_daemon_integration_spec.rb +0 -7
- data/spec/lib/http_stub/server_spec.rb +0 -234
- data/spec/support/http_stub/configurer/request/stub_payload_builder_shared_context.rb +0 -27
@@ -21,12 +21,22 @@ describe HttpStub::Configurer::Server::Facade do
|
|
21
21
|
|
22
22
|
describe "#stub_response" do
|
23
23
|
|
24
|
-
let(:
|
25
|
-
let(:
|
24
|
+
let(:model_description) { "some model description" }
|
25
|
+
let(:model) { instance_double(HttpStub::Configurer::Request::Stub, to_s: model_description) }
|
26
|
+
let(:request) { instance_double(HttpStub::Configurer::Request::Http::Multipart) }
|
26
27
|
|
27
|
-
subject { facade.stub_response(
|
28
|
+
subject { facade.stub_response(model) }
|
28
29
|
|
29
|
-
before(:example)
|
30
|
+
before(:example) do
|
31
|
+
allow(request_processor).to receive(:submit)
|
32
|
+
allow(HttpStub::Configurer::Request::Http::Factory).to receive(:stub).and_return(request)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "creates a stub request with the provided model" do
|
36
|
+
expect(HttpStub::Configurer::Request::Http::Factory).to receive(:stub).with(model)
|
37
|
+
|
38
|
+
subject
|
39
|
+
end
|
30
40
|
|
31
41
|
it "submits the stub request via the request processor" do
|
32
42
|
expect(request_processor).to receive(:submit).with(hash_including(request: request))
|
@@ -34,8 +44,8 @@ describe HttpStub::Configurer::Server::Facade do
|
|
34
44
|
subject
|
35
45
|
end
|
36
46
|
|
37
|
-
it "describes the
|
38
|
-
expect(request_processor).to receive(:submit).with(hash_including(description: "stubbing '#{
|
47
|
+
it "describes the model via its string representation" do
|
48
|
+
expect(request_processor).to receive(:submit).with(hash_including(description: "stubbing '#{model_description}'"))
|
39
49
|
|
40
50
|
subject
|
41
51
|
end
|
@@ -44,22 +54,32 @@ describe HttpStub::Configurer::Server::Facade do
|
|
44
54
|
|
45
55
|
describe "#stub_activator" do
|
46
56
|
|
47
|
-
let(:
|
48
|
-
let(:
|
57
|
+
let(:model_description) { "some model description" }
|
58
|
+
let(:model) { instance_double(HttpStub::Configurer::Request::StubActivator, to_s: model_description) }
|
59
|
+
let(:request) { instance_double(HttpStub::Configurer::Request::Http::Multipart) }
|
49
60
|
|
50
|
-
subject { facade.stub_activator(
|
61
|
+
subject { facade.stub_activator(model) }
|
51
62
|
|
52
|
-
before(:example)
|
63
|
+
before(:example) do
|
64
|
+
allow(request_processor).to receive(:submit)
|
65
|
+
allow(HttpStub::Configurer::Request::Http::Factory).to receive(:stub_activator).and_return(request)
|
66
|
+
end
|
53
67
|
|
54
|
-
it "
|
68
|
+
it "creates a stub activator request with the provided model" do
|
69
|
+
expect(HttpStub::Configurer::Request::Http::Factory).to receive(:stub_activator).with(model)
|
70
|
+
|
71
|
+
subject
|
72
|
+
end
|
73
|
+
|
74
|
+
it "submits the stub activator request via the request processor" do
|
55
75
|
expect(request_processor).to receive(:submit).with(hash_including(request: request))
|
56
76
|
|
57
77
|
subject
|
58
78
|
end
|
59
79
|
|
60
|
-
it "describes the
|
80
|
+
it "describes the model via its string representation" do
|
61
81
|
expect(request_processor).to(
|
62
|
-
receive(:submit).with(hash_including(description: "registering activator '#{
|
82
|
+
receive(:submit).with(hash_including(description: "registering activator '#{model_description}'"))
|
63
83
|
)
|
64
84
|
|
65
85
|
subject
|
@@ -70,22 +90,22 @@ describe HttpStub::Configurer::Server::Facade do
|
|
70
90
|
describe "#activate" do
|
71
91
|
|
72
92
|
let(:uri) { "/some/activation/uri" }
|
73
|
-
let(:request) { instance_double(
|
93
|
+
let(:request) { instance_double(HttpStub::Configurer::Request::Http::Basic) }
|
74
94
|
|
75
95
|
subject { facade.activate(uri) }
|
76
96
|
|
77
97
|
before(:example) do
|
78
|
-
allow(
|
98
|
+
allow(HttpStub::Configurer::Request::Http::Factory).to receive(:get).and_return(request)
|
79
99
|
allow(request_processor).to receive(:submit)
|
80
100
|
end
|
81
101
|
|
82
102
|
it "creates a GET request for the uri" do
|
83
|
-
expect(
|
103
|
+
expect(HttpStub::Configurer::Request::Http::Factory).to receive(:get).with(uri).and_return(request)
|
84
104
|
|
85
105
|
subject
|
86
106
|
end
|
87
107
|
|
88
|
-
it "submits the
|
108
|
+
it "submits the request via the request processor" do
|
89
109
|
expect(request_processor).to receive(:submit).with(hash_including(request: request))
|
90
110
|
|
91
111
|
subject
|
@@ -101,29 +121,22 @@ describe HttpStub::Configurer::Server::Facade do
|
|
101
121
|
|
102
122
|
describe "#remember_stubs" do
|
103
123
|
|
104
|
-
let(:request) { instance_double(
|
124
|
+
let(:request) { instance_double(HttpStub::Configurer::Request::Http::Basic) }
|
105
125
|
|
106
126
|
subject { facade.remember_stubs }
|
107
127
|
|
108
128
|
before(:example) do
|
109
|
-
allow(
|
110
|
-
allow(request).to receive(:body=)
|
129
|
+
allow(HttpStub::Configurer::Request::Http::Factory).to receive(:post).and_return(request)
|
111
130
|
allow(request_processor).to receive(:submit)
|
112
131
|
end
|
113
132
|
|
114
133
|
it "creates a POST request for /stubs/memory endpoint" do
|
115
|
-
expect(
|
116
|
-
|
117
|
-
subject
|
118
|
-
end
|
119
|
-
|
120
|
-
it "establishes an empty body on the POST request" do
|
121
|
-
expect(request).to receive(:body=).with("")
|
134
|
+
expect(HttpStub::Configurer::Request::Http::Factory).to receive(:post).with("/stubs/memory").and_return(request)
|
122
135
|
|
123
136
|
subject
|
124
137
|
end
|
125
138
|
|
126
|
-
it "submits the
|
139
|
+
it "submits the request via the request processor" do
|
127
140
|
expect(request_processor).to receive(:submit).with(hash_including(request: request))
|
128
141
|
|
129
142
|
subject
|
@@ -139,22 +152,22 @@ describe HttpStub::Configurer::Server::Facade do
|
|
139
152
|
|
140
153
|
describe "#recall_stubs" do
|
141
154
|
|
142
|
-
let(:request) { instance_double(
|
155
|
+
let(:request) { instance_double(HttpStub::Configurer::Request::Http::Basic) }
|
143
156
|
|
144
157
|
subject { facade.recall_stubs }
|
145
158
|
|
146
159
|
before(:example) do
|
147
|
-
allow(
|
160
|
+
allow(HttpStub::Configurer::Request::Http::Factory).to receive(:get).and_return(request)
|
148
161
|
allow(request_processor).to receive(:submit)
|
149
162
|
end
|
150
163
|
|
151
|
-
it "creates a
|
152
|
-
expect(
|
164
|
+
it "creates a GET request for /stubs/memory endpoint" do
|
165
|
+
expect(HttpStub::Configurer::Request::Http::Factory).to receive(:get).with("/stubs/memory").and_return(request)
|
153
166
|
|
154
167
|
subject
|
155
168
|
end
|
156
169
|
|
157
|
-
it "submits the
|
170
|
+
it "submits the request via the request processor" do
|
158
171
|
expect(request_processor).to receive(:submit).with(hash_including(request: request))
|
159
172
|
|
160
173
|
subject
|
@@ -170,22 +183,22 @@ describe HttpStub::Configurer::Server::Facade do
|
|
170
183
|
|
171
184
|
describe "#clear_stubs" do
|
172
185
|
|
173
|
-
let(:request) { instance_double(
|
186
|
+
let(:request) { instance_double(HttpStub::Configurer::Request::Http::Basic) }
|
174
187
|
|
175
188
|
subject { facade.clear_stubs }
|
176
189
|
|
177
190
|
before(:example) do
|
178
|
-
allow(
|
191
|
+
allow(HttpStub::Configurer::Request::Http::Factory).to receive(:delete).and_return(request)
|
179
192
|
allow(request_processor).to receive(:submit)
|
180
193
|
end
|
181
194
|
|
182
195
|
it "creates a DELETE request for the /stubs endpoint" do
|
183
|
-
expect(
|
196
|
+
expect(HttpStub::Configurer::Request::Http::Factory).to receive(:delete).with("/stubs").and_return(request)
|
184
197
|
|
185
198
|
subject
|
186
199
|
end
|
187
200
|
|
188
|
-
it "
|
201
|
+
it "submits the request via the request processor" do
|
189
202
|
expect(request_processor).to receive(:submit).with(hash_including(request: request))
|
190
203
|
|
191
204
|
subject
|
@@ -201,22 +214,24 @@ describe HttpStub::Configurer::Server::Facade do
|
|
201
214
|
|
202
215
|
describe "#clear_activators" do
|
203
216
|
|
204
|
-
let(:request) { instance_double(
|
217
|
+
let(:request) { instance_double(HttpStub::Configurer::Request::Http::Basic) }
|
205
218
|
|
206
219
|
subject { facade.clear_activators }
|
207
220
|
|
208
221
|
before(:example) do
|
209
|
-
allow(
|
222
|
+
allow(HttpStub::Configurer::Request::Http::Factory).to receive(:delete).and_return(request)
|
210
223
|
allow(request_processor).to receive(:submit)
|
211
224
|
end
|
212
225
|
|
213
226
|
it "creates a DELETE request for the /stubs/activators endpoint" do
|
214
|
-
expect(
|
227
|
+
expect(HttpStub::Configurer::Request::Http::Factory).to(
|
228
|
+
receive(:delete).with("/stubs/activators").and_return(request)
|
229
|
+
)
|
215
230
|
|
216
231
|
subject
|
217
232
|
end
|
218
233
|
|
219
|
-
it "
|
234
|
+
it "submits the HTTP Stub request via the request processor" do
|
220
235
|
expect(request_processor).to receive(:submit).with(hash_including(request: request))
|
221
236
|
|
222
237
|
subject
|