stacker_bee 2.1.0.pre227 → 2.1.0.pre228
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/stacker_bee/client.rb +2 -0
- data/lib/stacker_bee/middleware/error_message.rb +15 -0
- data/lib/stacker_bee/middleware/http_status.rb +0 -4
- data/spec/units/stacker_bee/middleware/error_message_spec.rb +34 -0
- data/spec/units/stacker_bee/middleware/http_status_spec.rb +1 -4
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDA2ODU4ZTIwYTgxMmFlYTIwZGNlYzJmNTg1MGUzNDg5NThlMjRjYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDMxMDUyNWFmZTc1ZTY2ZGQ2NTNmZGFmOGQ0MGY5NGFjZTRmZGM4YQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGRmMjc5NWY5MGUzYTY0NzhjY2FmNTNjOThkODYxODk1MjdlODQ3MDFmODkx
|
10
|
+
MWQwMjY2NmFjYTEwOWJjZmUwODZhNTNlZTE4MTgxZjU1MzNmOTMzZjI4NWIz
|
11
|
+
YjNmZGZjNTM3MzI4MTM3MDliOTkxNDhlY2VkY2IzNjQxYmI5ZGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTM0ZGJjNGIxYjk5YjdkMDRkZWJhMGE1ZWE5Y2RkNzIwNTQ3OWI3YzExN2Rh
|
14
|
+
YWJkOGZmNmVhNmRlMmM3NDRjMWU3ZjgzZDcxMzcxY2U5NmEwZjMzODFlZDUy
|
15
|
+
MDk5YWM3NTA5OTRmODU1Mzc5NzY4NjM4NjMxODMwMDAxYjJiMWQ=
|
data/lib/stacker_bee/client.rb
CHANGED
@@ -20,6 +20,7 @@ require "stacker_bee/middleware/clean_response"
|
|
20
20
|
require "stacker_bee/middleware/raise_on_http_error"
|
21
21
|
require "stacker_bee/middleware/http_status"
|
22
22
|
require "stacker_bee/middleware/console_access"
|
23
|
+
require "stacker_bee/middleware/error_message"
|
23
24
|
|
24
25
|
# rubocop:disable ClassLength
|
25
26
|
module StackerBee
|
@@ -46,6 +47,7 @@ module StackerBee
|
|
46
47
|
|
47
48
|
# response
|
48
49
|
builder.use Middleware::RaiseOnHTTPError
|
50
|
+
builder.use Middleware::ErrorMessage
|
49
51
|
builder.use Middleware::HTTPStatus
|
50
52
|
builder.use Middleware::CleanResponse
|
51
53
|
builder.use Middleware::RashifyResponse
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe StackerBee::Middleware::ErrorMessage do
|
4
|
+
subject { env.response }
|
5
|
+
before { middleware.after(env) }
|
6
|
+
|
7
|
+
let(:middleware) { described_class.new }
|
8
|
+
let(:env) do
|
9
|
+
StackerBee::Middleware::Environment.new.tap do |env|
|
10
|
+
env.response.body = body
|
11
|
+
env.response.success = is_success?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
let(:body) { { errortext: message } }
|
15
|
+
let(:message) { "Unable to execute API command deployvirtualmachine " }
|
16
|
+
let(:is_success?) { true }
|
17
|
+
|
18
|
+
it "doesn't apply to HTML responses" do
|
19
|
+
middleware.content_types.should_not match("text/html; charset=utf-8")
|
20
|
+
end
|
21
|
+
it "applies to JSON responses" do
|
22
|
+
middleware.content_types.should match("text/javascript; charset=utf-8")
|
23
|
+
end
|
24
|
+
|
25
|
+
context "given an error" do
|
26
|
+
let(:is_success?) { false }
|
27
|
+
its(:error) { should eq message }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "given a success" do
|
31
|
+
let(:is_success?) { true }
|
32
|
+
its(:error) { should be_nil }
|
33
|
+
end
|
34
|
+
end
|
@@ -11,15 +11,13 @@ describe StackerBee::Middleware::HTTPStatus do
|
|
11
11
|
env.response.body = body
|
12
12
|
end
|
13
13
|
end
|
14
|
-
let(:body) { { errorcode: http_status
|
15
|
-
let(:message) { "Unable to execute API command deployvirtualmachine " }
|
14
|
+
let(:body) { { errorcode: http_status } }
|
16
15
|
|
17
16
|
context "given an error" do
|
18
17
|
let(:http_status) { 431 }
|
19
18
|
let(:success?) { false }
|
20
19
|
|
21
20
|
its(:status) { should eq http_status }
|
22
|
-
its(:error) { should eq message }
|
23
21
|
it { should_not be_success }
|
24
22
|
end
|
25
23
|
|
@@ -28,7 +26,6 @@ describe StackerBee::Middleware::HTTPStatus do
|
|
28
26
|
let(:success?) { true }
|
29
27
|
|
30
28
|
its(:status) { should eq http_status }
|
31
|
-
its(:error) { should be_nil }
|
32
29
|
it { should be_success }
|
33
30
|
end
|
34
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stacker_bee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.0.
|
4
|
+
version: 2.1.0.pre228
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Sterndale
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -195,6 +195,7 @@ files:
|
|
195
195
|
- lib/stacker_bee/middleware/dictionary_flattener.rb
|
196
196
|
- lib/stacker_bee/middleware/endpoint_normalizer.rb
|
197
197
|
- lib/stacker_bee/middleware/environment.rb
|
198
|
+
- lib/stacker_bee/middleware/error_message.rb
|
198
199
|
- lib/stacker_bee/middleware/format_keys.rb
|
199
200
|
- lib/stacker_bee/middleware/format_values.rb
|
200
201
|
- lib/stacker_bee/middleware/http_status.rb
|
@@ -243,6 +244,7 @@ files:
|
|
243
244
|
- spec/units/stacker_bee/middleware/console_access_spec.rb
|
244
245
|
- spec/units/stacker_bee/middleware/dictionary_flattener_spec.rb
|
245
246
|
- spec/units/stacker_bee/middleware/endpoint_normalizer_spec.rb
|
247
|
+
- spec/units/stacker_bee/middleware/error_message_spec.rb
|
246
248
|
- spec/units/stacker_bee/middleware/format_keys_spec.rb
|
247
249
|
- spec/units/stacker_bee/middleware/format_values_spec.rb
|
248
250
|
- spec/units/stacker_bee/middleware/http_status_spec.rb
|
@@ -315,6 +317,7 @@ test_files:
|
|
315
317
|
- spec/units/stacker_bee/middleware/console_access_spec.rb
|
316
318
|
- spec/units/stacker_bee/middleware/dictionary_flattener_spec.rb
|
317
319
|
- spec/units/stacker_bee/middleware/endpoint_normalizer_spec.rb
|
320
|
+
- spec/units/stacker_bee/middleware/error_message_spec.rb
|
318
321
|
- spec/units/stacker_bee/middleware/format_keys_spec.rb
|
319
322
|
- spec/units/stacker_bee/middleware/format_values_spec.rb
|
320
323
|
- spec/units/stacker_bee/middleware/http_status_spec.rb
|