batch_api 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/changelog.md +14 -0
- data/lib/batch_api/configuration.rb +1 -1
- data/lib/batch_api/internal_middleware/decode_json_body.rb +7 -3
- data/lib/batch_api/operation/rack.rb +4 -1
- data/lib/batch_api/version.rb +1 -1
- data/readme.md +2 -2
- data/spec/dummy/Gemfile +1 -0
- data/spec/dummy/Gemfile.lock +8 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config/application.rb +6 -37
- data/spec/dummy/config/boot.rb +2 -9
- data/spec/dummy/config/environment.rb +3 -3
- data/spec/dummy/config/environments/development.rb +22 -18
- data/spec/dummy/config/environments/production.rb +46 -34
- data/spec/dummy/config/environments/test.rb +19 -14
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +6 -5
- data/spec/dummy/config/initializers/mime_types.rb +0 -1
- data/spec/dummy/config/initializers/session_store.rb +1 -6
- data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
- data/spec/dummy/config/locales/en.yml +20 -2
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/log/test.log +7369 -46081
- data/spec/lib/batch_api_spec.rb +3 -3
- data/spec/lib/batch_error_spec.rb +3 -3
- data/spec/lib/configuration_spec.rb +3 -3
- data/spec/lib/error_wrapper_spec.rb +20 -20
- data/spec/lib/internal_middleware/decode_json_body_spec.rb +13 -6
- data/spec/lib/internal_middleware/response_filter_spec.rb +3 -3
- data/spec/lib/internal_middleware_spec.rb +15 -13
- data/spec/lib/operation/rack_spec.rb +58 -50
- data/spec/lib/operation/rails_spec.rb +10 -10
- data/spec/lib/processor/executor_spec.rb +5 -5
- data/spec/lib/processor/sequential_spec.rb +10 -10
- data/spec/lib/processor_spec.rb +23 -21
- data/spec/lib/rack_middleware_spec.rb +17 -17
- data/spec/lib/response_spec.rb +9 -9
- data/spec/{integration → rack-integration}/rails_spec.rb +3 -3
- data/spec/{integration → rack-integration}/shared_examples.rb +24 -18
- data/spec/{integration → rack-integration}/sinatra_integration_spec.rb +5 -0
- data/spec/spec_helper.rb +15 -1
- data/spec/support/sinatra_xhr.rb +13 -0
- metadata +47 -135
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -1742
@@ -12,27 +12,27 @@ describe BatchApi::Operation::Rails do
|
|
12
12
|
|
13
13
|
# for env, see bottom of file - it's long
|
14
14
|
let(:operation) { BatchApi::Operation::Rails.new(op_params, env, app) }
|
15
|
-
let(:app) {
|
15
|
+
let(:app) { double("application", call: [200, {}, ["foo"]]) }
|
16
16
|
let(:path_params) { {controller: "batch_api/batch", action: "batch"} }
|
17
17
|
let(:mixed_params) { op_params["params"].merge(path_params) }
|
18
18
|
|
19
19
|
before :each do
|
20
|
-
::Rails.application.routes.
|
20
|
+
allow(::Rails.application.routes).to receive(:recognize_path).and_return(path_params)
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "#initialize" do
|
24
24
|
it "merges in the Rails path params" do
|
25
|
-
::Rails.application.routes.
|
25
|
+
expect(::Rails.application.routes).to receive(:recognize_path).with(
|
26
26
|
op_params["url"],
|
27
27
|
op_params
|
28
28
|
).and_return(path_params)
|
29
29
|
|
30
|
-
operation.params.
|
30
|
+
expect(operation.params).to include(path_params)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "doesn't change the params if the path isn't recognized" do
|
34
|
-
::Rails.application.routes.
|
35
|
-
operation.params.
|
34
|
+
allow(::Rails.application.routes).to receive(:recognize_path).and_raise(StandardError)
|
35
|
+
expect(operation.params).to eq(op_params["params"])
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -41,14 +41,14 @@ describe BatchApi::Operation::Rails do
|
|
41
41
|
|
42
42
|
it "updates the ActionDispatch params" do
|
43
43
|
key = "action_dispatch.request.parameters"
|
44
|
-
processed_env[key].
|
45
|
-
processed_env[key].
|
44
|
+
expect(processed_env[key]).not_to eq(env[key])
|
45
|
+
expect(processed_env[key]).to eq(mixed_params)
|
46
46
|
end
|
47
47
|
|
48
48
|
it "updates the ActionDispatch request params" do
|
49
49
|
key = "action_dispatch.request.request_parameters"
|
50
|
-
processed_env[key].
|
51
|
-
processed_env[key].
|
50
|
+
expect(processed_env[key]).not_to eq(env[key])
|
51
|
+
expect(processed_env[key]).to eq(mixed_params)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -3,20 +3,20 @@ require 'batch_api/processor/executor'
|
|
3
3
|
|
4
4
|
describe BatchApi::Processor::Executor do
|
5
5
|
|
6
|
-
let(:app) {
|
6
|
+
let(:app) { double("app", call: double) }
|
7
7
|
let(:executor) { BatchApi::Processor::Executor.new(app) }
|
8
|
-
let(:result) {
|
9
|
-
let(:op) {
|
8
|
+
let(:result) { double("result") }
|
9
|
+
let(:op) { double("operation", execute: result) }
|
10
10
|
let(:env) { {op: op} }
|
11
11
|
|
12
12
|
describe "#call" do
|
13
13
|
it "executes the operation" do
|
14
|
-
op.
|
14
|
+
expect(op).to receive(:execute)
|
15
15
|
executor.call(env)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "returns the result" do
|
19
|
-
executor.call(env).
|
19
|
+
expect(executor.call(env)).to eq(result)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -2,38 +2,38 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe BatchApi::Processor::Sequential do
|
4
4
|
|
5
|
-
let(:app) {
|
5
|
+
let(:app) { double("app", call: double) }
|
6
6
|
let(:sequential) { BatchApi::Processor::Sequential.new(app) }
|
7
7
|
|
8
8
|
describe "#call" do
|
9
|
-
let(:call_results) { 3.times.collect {|i|
|
9
|
+
let(:call_results) { 3.times.collect {|i| double("called #{i}") } }
|
10
10
|
let(:env) { {
|
11
|
-
ops: 3.times.collect {|i|
|
11
|
+
ops: 3.times.collect {|i| double("op #{i}") }
|
12
12
|
} }
|
13
|
-
let(:op_middleware) {
|
13
|
+
let(:op_middleware) { double("middleware", call: {}) }
|
14
14
|
|
15
15
|
before :each do
|
16
|
-
BatchApi::InternalMiddleware.
|
17
|
-
|
18
|
-
op_middleware.
|
16
|
+
allow(BatchApi::InternalMiddleware).
|
17
|
+
to receive(:operation_stack).and_return(op_middleware)
|
18
|
+
allow(op_middleware).to receive(:call).and_return(*call_results)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "creates an operation middleware stack and calls it for each op" do
|
22
22
|
env[:ops].each {|op|
|
23
|
-
op_middleware.
|
23
|
+
expect(op_middleware).to receive(:call).
|
24
24
|
with(hash_including(op: op)).ordered
|
25
25
|
}
|
26
26
|
sequential.call(env)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "includes the rest of the env in the calls" do
|
30
|
-
op_middleware.
|
30
|
+
expect(op_middleware).to receive(:call).
|
31
31
|
with(hash_including(env)).exactly(3).times
|
32
32
|
sequential.call(env)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "returns the results of the calls" do
|
36
|
-
sequential.call(env).
|
36
|
+
expect(sequential.call(env)).to eq(call_results)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/spec/lib/processor_spec.rb
CHANGED
@@ -26,36 +26,36 @@ describe BatchApi::Processor do
|
|
26
26
|
|
27
27
|
let(:request) {
|
28
28
|
Rack::Request.new(env).tap do |r|
|
29
|
-
r.
|
29
|
+
allow(r).to receive(:params).and_return({}.merge("ops" => ops).merge(options))
|
30
30
|
end
|
31
31
|
}
|
32
|
-
let(:app) {
|
32
|
+
let(:app) { double("application", call: [200, {}, ["foo"]]) }
|
33
33
|
let(:processor) { BatchApi::Processor.new(request, app) }
|
34
34
|
|
35
35
|
describe "#initialize" do
|
36
36
|
# this may be brittle...consider refactoring?
|
37
37
|
it "turns the ops params into processed operations at #ops" do
|
38
38
|
# simulate receiving several operations
|
39
|
-
klass =
|
40
|
-
BatchApi::Processor.
|
41
|
-
operation_objects = 3.times.collect {
|
39
|
+
klass = double("op class")
|
40
|
+
allow(BatchApi::Processor).to receive(:operation_klass).and_return(klass)
|
41
|
+
operation_objects = 3.times.collect { double("operation object") }
|
42
42
|
operation_params = 3.times.collect do |i|
|
43
|
-
|
44
|
-
klass.
|
43
|
+
double("raw operation").tap do |o|
|
44
|
+
expect(klass).to receive(:new)
|
45
45
|
.with(o, env, app).and_return(operation_objects[i])
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
request.params["ops"] = operation_params
|
50
|
-
BatchApi::Processor.new(request, app).ops.
|
50
|
+
expect(BatchApi::Processor.new(request, app).ops).to eq(operation_objects)
|
51
51
|
end
|
52
52
|
|
53
53
|
it "makes the options available" do
|
54
|
-
BatchApi::Processor.new(request, app).options.
|
54
|
+
expect(BatchApi::Processor.new(request, app).options).to eq(options)
|
55
55
|
end
|
56
56
|
|
57
57
|
it "makes the app available" do
|
58
|
-
BatchApi::Processor.new(request, app).app.
|
58
|
+
expect(BatchApi::Processor.new(request, app).app).to eq(app)
|
59
59
|
end
|
60
60
|
|
61
61
|
context "error conditions" do
|
@@ -89,13 +89,13 @@ describe BatchApi::Processor do
|
|
89
89
|
|
90
90
|
describe "#strategy" do
|
91
91
|
it "returns BatchApi::Processor::Sequential" do
|
92
|
-
processor.strategy.
|
92
|
+
expect(processor.strategy).to eq(BatchApi::Processor::Sequential)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
96
|
describe "#execute!" do
|
97
|
-
let(:result) {
|
98
|
-
let(:stack) {
|
97
|
+
let(:result) { double("result") }
|
98
|
+
let(:stack) { double("stack", call: result) }
|
99
99
|
let(:middleware_env) { {
|
100
100
|
ops: processor.ops, # the processed Operation objects
|
101
101
|
rack_env: env,
|
@@ -104,31 +104,33 @@ describe BatchApi::Processor do
|
|
104
104
|
} }
|
105
105
|
|
106
106
|
before :each do
|
107
|
-
BatchApi::InternalMiddleware.
|
107
|
+
allow(BatchApi::InternalMiddleware).to receive(:batch_stack).and_return(stack)
|
108
108
|
end
|
109
109
|
|
110
110
|
it "calls an internal middleware stacks with the appropriate data" do
|
111
|
-
stack.
|
111
|
+
expect(stack).to receive(:call).with(middleware_env)
|
112
112
|
processor.execute!
|
113
113
|
end
|
114
114
|
|
115
115
|
it "returns the formatted result of the strategy" do
|
116
|
-
stack.
|
117
|
-
processor.execute!["results"].
|
116
|
+
allow(stack).to receive(:call).and_return(stubby = double)
|
117
|
+
expect(processor.execute!["results"]).to eq(stubby)
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
121
|
describe ".operation_klass" do
|
122
122
|
it "returns BatchApi::Operation::Rack if !Rails" do
|
123
|
-
BatchApi.
|
124
|
-
BatchApi::Processor.operation_klass.
|
123
|
+
allow(BatchApi).to receive(:rails?).and_return(false)
|
124
|
+
expect(BatchApi::Processor.operation_klass).to eq(
|
125
125
|
BatchApi::Operation::Rack
|
126
|
+
)
|
126
127
|
end
|
127
128
|
|
128
129
|
it "returns BatchApi::Operation::Rails if Rails" do
|
129
|
-
BatchApi.
|
130
|
-
BatchApi::Processor.operation_klass.
|
130
|
+
allow(BatchApi).to receive(:rails?).and_return(true)
|
131
|
+
expect(BatchApi::Processor.operation_klass).to eq(
|
131
132
|
BatchApi::Operation::Rails
|
133
|
+
)
|
132
134
|
end
|
133
135
|
end
|
134
136
|
end
|
@@ -4,17 +4,17 @@ describe BatchApi::RackMiddleware do
|
|
4
4
|
describe "#initialize" do
|
5
5
|
it "allows access to the BatchApi configuration" do
|
6
6
|
limit = rand * 100
|
7
|
-
middleware = BatchApi::RackMiddleware.new(
|
7
|
+
middleware = BatchApi::RackMiddleware.new(double("app")) do |conf|
|
8
8
|
conf.limit = limit
|
9
9
|
end
|
10
|
-
BatchApi.config.limit.
|
10
|
+
expect(BatchApi.config.limit).to eq(limit)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "#call" do
|
15
15
|
let(:endpoint) { "/foo/bar" }
|
16
16
|
let(:verb) { "run" }
|
17
|
-
let(:app) {
|
17
|
+
let(:app) { double("app") }
|
18
18
|
|
19
19
|
let(:middleware) {
|
20
20
|
BatchApi::RackMiddleware.new(app) do |conf|
|
@@ -47,42 +47,42 @@ describe BatchApi::RackMiddleware do
|
|
47
47
|
|
48
48
|
let(:request) { Rack::Request.new(env) }
|
49
49
|
let(:result) { {a: 2, b: {c: 3}} }
|
50
|
-
let(:processor) {
|
50
|
+
let(:processor) { double("processor", :execute! => result) }
|
51
51
|
|
52
52
|
before :each do
|
53
|
-
BatchApi::Processor.
|
53
|
+
allow(BatchApi::Processor).to receive(:new).and_return(processor)
|
54
54
|
end
|
55
55
|
|
56
56
|
it "processes the batch request" do
|
57
|
-
Rack::Request.
|
58
|
-
BatchApi::Processor.
|
57
|
+
allow(Rack::Request).to receive(:new).with(env).and_return(request)
|
58
|
+
expect(BatchApi::Processor).to receive(:new).with(request, app).and_return(processor)
|
59
59
|
middleware.call(env)
|
60
60
|
end
|
61
61
|
|
62
62
|
context "for a successful set of calls" do
|
63
63
|
it "returns the JSON-encoded result as the body" do
|
64
64
|
output = middleware.call(env)
|
65
|
-
output[2].
|
65
|
+
expect(output[2]).to eq([MultiJson.dump(result)])
|
66
66
|
end
|
67
67
|
|
68
68
|
it "returns a 200" do
|
69
|
-
middleware.call(env)[0].
|
69
|
+
expect(middleware.call(env)[0]).to eq(200)
|
70
70
|
end
|
71
71
|
|
72
72
|
it "sets the content type" do
|
73
|
-
middleware.call(env)[1].
|
73
|
+
expect(middleware.call(env)[1]).to include("Content-Type" => "application/json")
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
context "for BatchApi errors" do
|
78
78
|
it "returns a rendered ErrorWrapper" do
|
79
|
-
err, result = StandardError.new,
|
80
|
-
error =
|
81
|
-
BatchApi::Processor.
|
82
|
-
BatchApi::ErrorWrapper.
|
79
|
+
err, result = StandardError.new, double
|
80
|
+
error = double("error object", render: result)
|
81
|
+
allow(BatchApi::Processor).to receive(:new).and_raise(err)
|
82
|
+
expect(BatchApi::ErrorWrapper).to receive(:new).with(err).and_return(
|
83
83
|
error
|
84
84
|
)
|
85
|
-
middleware.call(env).
|
85
|
+
expect(middleware.call(env)).to eq(result)
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
@@ -94,8 +94,8 @@ describe BatchApi::RackMiddleware do
|
|
94
94
|
} }
|
95
95
|
|
96
96
|
it "just calls the app onward and returns the result" do
|
97
|
-
output =
|
98
|
-
app.
|
97
|
+
output = double("output")
|
98
|
+
expect(app).to receive(:call).with(env).and_return(output)
|
99
99
|
middleware.call(env)
|
100
100
|
end
|
101
101
|
end
|
data/spec/lib/response_spec.rb
CHANGED
@@ -9,45 +9,45 @@ describe BatchApi::Response do
|
|
9
9
|
[:status, :body, :headers].each do |attr|
|
10
10
|
local_attr = attr
|
11
11
|
it "has an accessor for #{local_attr}" do
|
12
|
-
response.
|
12
|
+
expect(response).to respond_to(local_attr)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "#initialize" do
|
17
17
|
it "sets status to the HTTP status code" do
|
18
|
-
response.status.
|
18
|
+
expect(response.status).to eq(raw_response.first)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "sets body to the HTTP body turned into a string" do
|
22
|
-
response.body.
|
22
|
+
expect(response.body).to eq(raw_response[2].join)
|
23
23
|
end
|
24
24
|
|
25
25
|
it "sets headers to the HTTP headers" do
|
26
|
-
response.headers.
|
26
|
+
expect(response.headers).to eq(raw_response[1])
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "#as_json" do
|
31
31
|
it "creates the expected hash" do
|
32
|
-
response.as_json.
|
32
|
+
expect(response.as_json).to eq({
|
33
33
|
body: response.body,
|
34
34
|
status: response.status,
|
35
35
|
headers: response.headers
|
36
|
-
}
|
36
|
+
})
|
37
37
|
end
|
38
38
|
|
39
39
|
it "accepts options" do
|
40
|
-
response.as_json(foo: :bar).
|
40
|
+
expect(response.as_json(foo: :bar)).not_to be_nil
|
41
41
|
end
|
42
42
|
|
43
43
|
it "leaves out items that are blank" do
|
44
44
|
response.status = response.body = nil
|
45
|
-
response.as_json.
|
45
|
+
expect(response.as_json).to eq({headers: raw_response[1]})
|
46
46
|
end
|
47
47
|
|
48
48
|
it "includes items that are false" do
|
49
49
|
response.body = false
|
50
|
-
response.as_json[:body].
|
50
|
+
expect(response.as_json[:body]).to eq(false)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require_relative './shared_examples'
|
3
3
|
|
4
|
-
describe "Rails integration specs" do
|
4
|
+
describe "Rails integration specs", type: :request do
|
5
5
|
before :each do
|
6
|
-
BatchApi.
|
6
|
+
allow(BatchApi).to receive(:rails?).and_return(true)
|
7
7
|
end
|
8
8
|
|
9
9
|
it_should_behave_like "integrating with a server"
|
10
|
-
end
|
10
|
+
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
shared_examples_for "a get request" do
|
2
2
|
it "returns the body as objects" do
|
3
3
|
@result = JSON.parse(response.body)["results"][0]
|
4
|
-
@result["body"].
|
4
|
+
expect(@result["body"]).to eq(get_result[:body])
|
5
5
|
end
|
6
6
|
|
7
7
|
it "returns the expected status" do
|
8
|
-
@result["status"].
|
8
|
+
expect(@result["status"]).to eq(get_result[:status])
|
9
9
|
end
|
10
10
|
|
11
11
|
it "returns the expected headers" do
|
12
|
-
@result["headers"].
|
12
|
+
expect(@result["headers"]).to include(get_result[:headers])
|
13
13
|
end
|
14
14
|
|
15
15
|
it "verifies that the right headers were received" do
|
16
|
-
@result["headers"]["REQUEST_HEADERS"].
|
16
|
+
expect(@result["headers"]["REQUEST_HEADERS"]).to include(
|
17
17
|
headerize(get_headers)
|
18
18
|
)
|
19
19
|
end
|
@@ -32,7 +32,7 @@ shared_examples_for "integrating with a server" do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
before :each do
|
35
|
-
BatchApi::ErrorWrapper.
|
35
|
+
allow(BatchApi::ErrorWrapper).to receive(:expose_backtrace?).and_return(false)
|
36
36
|
end
|
37
37
|
|
38
38
|
# these are defined in the dummy app's endpoints controller
|
@@ -142,7 +142,8 @@ shared_examples_for "integrating with a server" do
|
|
142
142
|
|
143
143
|
before :each do
|
144
144
|
@t = Time.now
|
145
|
-
|
145
|
+
begin
|
146
|
+
post "/batch", {
|
146
147
|
ops: [
|
147
148
|
get_request,
|
148
149
|
post_request,
|
@@ -155,14 +156,19 @@ shared_examples_for "integrating with a server" do
|
|
155
156
|
],
|
156
157
|
sequential: true
|
157
158
|
}.to_json, "CONTENT_TYPE" => "application/json"
|
159
|
+
rescue => err
|
160
|
+
puts err.message
|
161
|
+
puts err.backtrace.join("\n")
|
162
|
+
raise
|
163
|
+
end
|
158
164
|
end
|
159
165
|
|
160
166
|
it "returns a 200" do
|
161
|
-
response.status.
|
167
|
+
expect(response.status).to eq(200)
|
162
168
|
end
|
163
169
|
|
164
170
|
it "includes results" do
|
165
|
-
JSON.parse(response.body)["results"].
|
171
|
+
expect(JSON.parse(response.body)["results"]).to be_a(Array)
|
166
172
|
end
|
167
173
|
|
168
174
|
context "for a get request" do
|
@@ -190,7 +196,7 @@ shared_examples_for "integrating with a server" do
|
|
190
196
|
end
|
191
197
|
|
192
198
|
it "properly parses the URL segment as a paramer" do
|
193
|
-
@result["body"].
|
199
|
+
expect(@result["body"]).to eq(parameter_result[:body])
|
194
200
|
end
|
195
201
|
end
|
196
202
|
end
|
@@ -202,19 +208,19 @@ shared_examples_for "integrating with a server" do
|
|
202
208
|
end
|
203
209
|
|
204
210
|
it "returns the body as objects (since DecodeJsonBody is default)" do
|
205
|
-
@result["body"].
|
211
|
+
expect(@result["body"]).to eq(post_result[:body])
|
206
212
|
end
|
207
213
|
|
208
214
|
it "returns the expected status" do
|
209
|
-
@result["status"].
|
215
|
+
expect(@result["status"]).to eq(post_result[:status])
|
210
216
|
end
|
211
217
|
|
212
218
|
it "returns the expected headers" do
|
213
|
-
@result["headers"].
|
219
|
+
expect(@result["headers"]).to include(post_result[:headers])
|
214
220
|
end
|
215
221
|
|
216
222
|
it "verifies that the right headers were received" do
|
217
|
-
@result["headers"]["REQUEST_HEADERS"].
|
223
|
+
expect(@result["headers"]["REQUEST_HEADERS"]).to include(headerize(post_headers))
|
218
224
|
end
|
219
225
|
end
|
220
226
|
end
|
@@ -225,13 +231,13 @@ shared_examples_for "integrating with a server" do
|
|
225
231
|
end
|
226
232
|
|
227
233
|
it "returns the right status" do
|
228
|
-
@result["status"].
|
234
|
+
expect(@result["status"]).to eq(error_response[:status])
|
229
235
|
end
|
230
236
|
|
231
237
|
it "returns the right error information" do
|
232
238
|
# we don't care about the backtrace,
|
233
239
|
# the main thing is that the messsage arrives
|
234
|
-
@result["body"]["error"].
|
240
|
+
expect(@result["body"]["error"]).to include(error_response[:body]["error"])
|
235
241
|
end
|
236
242
|
end
|
237
243
|
|
@@ -241,7 +247,7 @@ shared_examples_for "integrating with a server" do
|
|
241
247
|
end
|
242
248
|
|
243
249
|
it "returns the right status" do
|
244
|
-
@result["status"].
|
250
|
+
expect(@result["status"]).to eq(404)
|
245
251
|
end
|
246
252
|
end
|
247
253
|
|
@@ -251,7 +257,7 @@ shared_examples_for "integrating with a server" do
|
|
251
257
|
end
|
252
258
|
|
253
259
|
it "returns nothing" do
|
254
|
-
@result.
|
260
|
+
expect(@result).to eq({})
|
255
261
|
end
|
256
262
|
end
|
257
263
|
|
@@ -261,7 +267,7 @@ shared_examples_for "integrating with a server" do
|
|
261
267
|
end
|
262
268
|
|
263
269
|
it "returns a regular result" do
|
264
|
-
@result.keys.
|
270
|
+
expect(@result.keys).not_to be_empty
|
265
271
|
end
|
266
272
|
end
|
267
273
|
end
|