stacker_bee 2.1.1.pre263 → 2.1.1.pre265
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 +8 -8
- data/spec/integration/request_spec.rb +7 -7
- data/spec/spec_helper.rb +3 -1
- data/spec/units/stacker_bee/api_spec.rb +4 -4
- data/spec/units/stacker_bee/client_spec.rb +4 -4
- data/spec/units/stacker_bee/configuration_spec.rb +31 -31
- data/spec/units/stacker_bee/connection_spec.rb +15 -8
- data/spec/units/stacker_bee/middleware/adapter_spec.rb +6 -6
- data/spec/units/stacker_bee/middleware/base_spec.rb +13 -13
- data/spec/units/stacker_bee/middleware/console_access_spec.rb +8 -8
- data/spec/units/stacker_bee/middleware/dictionary_flattener_spec.rb +11 -11
- data/spec/units/stacker_bee/middleware/endpoint_normalizer_spec.rb +4 -4
- data/spec/units/stacker_bee/middleware/error_message_spec.rb +2 -2
- data/spec/units/stacker_bee/middleware/format_keys_spec.rb +4 -4
- data/spec/units/stacker_bee/middleware/http_status_spec.rb +2 -2
- data/spec/units/stacker_bee/middleware/log_response_spec.rb +7 -7
- data/spec/units/stacker_bee/middleware/raise_on_http_errors_spec.rb +1 -1
- data/spec/units/stacker_bee/middleware/remove_empty_strings_spec.rb +5 -3
- data/spec/units/stacker_bee/middleware/remove_nils_spec.rb +2 -2
- data/spec/units/stacker_bee/rash_spec.rb +14 -14
- data/spec/units/stacker_bee/request_error_spec.rb +3 -3
- data/spec/units/stacker_bee/utilities_spec.rb +25 -25
- data/spec/units/stacker_bee_spec.rb +1 -1
- data/stacker_bee.gemspec +6 -5
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWM0OWQ4YTM0YTM4ZTgyMDBhZWQwNmMxZWQ2YzZiMGI1NGM3MTM0MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzZlNDg5ZTNkYjc1ZWIyMDBlMzAzMjJlNjIyMGVhZjIxMDU2YTgyNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmU2YjhlY2M5ZmYzZGYwNTUxNTk1ZmZkMGRjYjViMTVmYWVhOGVlZTMwMjE0
|
10
|
+
OWI0NDIzYzY3MjA5YzEyNmFlMzc2ZWNkZGZlNzY2MmFkODJmODg1ZDU4MzE2
|
11
|
+
OThhNzU3NTQxZWJmNjM2MWQ0NWI3MmVjZGJkYzdmNTU0ODZjNmE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2Q4Y2MxOWE4NjczMzI3NGEyYjg0MTI2M2U4MzFiYjM1ZmM2MTg2ZTc3ZmU1
|
14
|
+
NGQzYzExZTRhNjk3MzA3MTI2NWQ0MGRmMDFiOTNjNjBkMjE0M2Q4NDQ0Y2Ji
|
15
|
+
NDc4MjJmOWJjMTM5ZWFkMTczYTQ5ZDkzMWEyOGJhOTUzNWRmNDM=
|
@@ -19,11 +19,11 @@ describe 'A response to a request sent to the CloudStack API', :vcr do
|
|
19
19
|
StackerBee::Client.new(config_hash)
|
20
20
|
end
|
21
21
|
|
22
|
-
it {
|
22
|
+
it { is_expected.not_to be_empty }
|
23
23
|
|
24
24
|
context 'first item' do
|
25
25
|
subject { client.list_accounts.first }
|
26
|
-
it {
|
26
|
+
it { is_expected.to include 'id' }
|
27
27
|
its(['accounttype']) { should be_a Numeric }
|
28
28
|
its(['account_type']) { should be_a Numeric }
|
29
29
|
end
|
@@ -41,7 +41,7 @@ describe 'A response to a request sent to the CloudStack API', :vcr do
|
|
41
41
|
it 'makes request with trailing slash' do
|
42
42
|
stub = stub_request(:get, /#{url}/).to_return(body: '{"foo": {}}')
|
43
43
|
subject
|
44
|
-
stub.
|
44
|
+
expect(stub).to have_been_requested
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -84,9 +84,9 @@ describe 'A response to a request sent to the CloudStack API', :vcr do
|
|
84
84
|
context 'a request parameter with an Array', :regression do
|
85
85
|
subject { client.list_hosts(params).first.keys }
|
86
86
|
let(:params) { { page: 1, pagesize: 1, details: [:events, :stats] } }
|
87
|
-
it {
|
88
|
-
it {
|
89
|
-
it {
|
87
|
+
it { is_expected.to include 'cpuused' }
|
88
|
+
it { is_expected.to include 'events' }
|
89
|
+
it { is_expected.not_to include 'cpuallocated' }
|
90
90
|
end
|
91
91
|
|
92
92
|
context 'a request parameter with a map' do
|
@@ -113,7 +113,7 @@ describe 'A response to a request sent to the CloudStack API', :vcr do
|
|
113
113
|
end
|
114
114
|
|
115
115
|
it 'can create an object' do
|
116
|
-
tag.
|
116
|
+
expect(tag).not_to be_nil
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
data/spec/spec_helper.rb
CHANGED
@@ -23,7 +23,7 @@ support_files = Dir[File.join(
|
|
23
23
|
support_files.each { |f| require f }
|
24
24
|
|
25
25
|
RSpec.configure do |config|
|
26
|
-
config.
|
26
|
+
config.raise_errors_for_deprecations!
|
27
27
|
config.run_all_when_everything_filtered = true
|
28
28
|
config.filter_run :focus
|
29
29
|
|
@@ -37,3 +37,5 @@ RSpec.configure do |config|
|
|
37
37
|
StackerBee::Client.reset!
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
41
|
+
require 'rspec/its'
|
@@ -17,8 +17,8 @@ describe StackerBee::API do
|
|
17
17
|
its(['getVmPassword']) { should be_a Hash }
|
18
18
|
its(['getWRONG']) { should be_nil }
|
19
19
|
|
20
|
-
it {
|
21
|
-
it {
|
22
|
-
it {
|
23
|
-
it {
|
20
|
+
it { is_expected.to be_key 'get_vm_password' }
|
21
|
+
it { is_expected.to be_key 'getvmpassword' }
|
22
|
+
it { is_expected.to be_key 'getVMPassword' }
|
23
|
+
it { is_expected.to be_key 'getVmPassword' }
|
24
24
|
end
|
@@ -5,7 +5,7 @@ describe StackerBee::Client, '.api' do
|
|
5
5
|
subject { described_class }
|
6
6
|
let(:api) { double }
|
7
7
|
before do
|
8
|
-
StackerBee::API.
|
8
|
+
allow(StackerBee::API).to receive_messages new: api
|
9
9
|
described_class.api_path = nil
|
10
10
|
end
|
11
11
|
its(:api_path) { should_not be_nil }
|
@@ -46,17 +46,17 @@ describe StackerBee::Client, 'calling endpoint' do
|
|
46
46
|
|
47
47
|
describe 'responding to methods' do
|
48
48
|
subject { client }
|
49
|
-
it {
|
49
|
+
it { is_expected.to respond_to endpoint_name }
|
50
50
|
end
|
51
51
|
|
52
52
|
describe 'via a method call' do
|
53
53
|
subject { client.list_virtual_machines(params) }
|
54
|
-
it {
|
54
|
+
it { is_expected.to eq response_body }
|
55
55
|
end
|
56
56
|
|
57
57
|
describe 'via #request' do
|
58
58
|
subject { client.request(endpoint_name, params) }
|
59
|
-
it {
|
59
|
+
it { is_expected.to eq response_body }
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -15,17 +15,17 @@ describe StackerBee::Configuration do
|
|
15
15
|
|
16
16
|
context 'when not set' do
|
17
17
|
let(:configuration) { described_class.new }
|
18
|
-
it {
|
18
|
+
it { is_expected.to eq true }
|
19
19
|
end
|
20
20
|
|
21
21
|
context 'when set to false' do
|
22
22
|
let(:configuration) { described_class.new(ssl_verify: false) }
|
23
|
-
it {
|
23
|
+
it { is_expected.to eq false }
|
24
24
|
end
|
25
25
|
|
26
26
|
context 'when set to true' do
|
27
27
|
let(:configuration) { described_class.new(ssl_verify: true) }
|
28
|
-
it {
|
28
|
+
it { is_expected.to eq true }
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -34,13 +34,13 @@ describe StackerBee::Configuration do
|
|
34
34
|
|
35
35
|
context 'when not set' do
|
36
36
|
let(:configuration) { described_class.new }
|
37
|
-
it {
|
37
|
+
it { is_expected.to eq nil }
|
38
38
|
end
|
39
39
|
|
40
40
|
context 'when set' do
|
41
41
|
let(:configuration) { described_class.new(url: setting) }
|
42
42
|
let(:setting) { 'http://example.com' }
|
43
|
-
it {
|
43
|
+
it { is_expected.to eq setting }
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -49,13 +49,13 @@ describe StackerBee::Configuration do
|
|
49
49
|
|
50
50
|
context 'when not set' do
|
51
51
|
let(:configuration) { described_class.new }
|
52
|
-
it {
|
52
|
+
it { is_expected.to eq nil }
|
53
53
|
end
|
54
54
|
|
55
55
|
context 'when set' do
|
56
56
|
let(:configuration) { described_class.new(secret_key: setting) }
|
57
57
|
let(:setting) { 'qwertyuiop' }
|
58
|
-
it {
|
58
|
+
it { is_expected.to eq setting }
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -64,13 +64,13 @@ describe StackerBee::Configuration do
|
|
64
64
|
|
65
65
|
context 'when not set' do
|
66
66
|
let(:configuration) { described_class.new }
|
67
|
-
it {
|
67
|
+
it { is_expected.to eq nil }
|
68
68
|
end
|
69
69
|
|
70
70
|
context 'when set' do
|
71
71
|
let(:configuration) { described_class.new(api_key: setting) }
|
72
72
|
let(:setting) { 'qwertyuiop' }
|
73
|
-
it {
|
73
|
+
it { is_expected.to eq setting }
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -79,13 +79,13 @@ describe StackerBee::Configuration do
|
|
79
79
|
|
80
80
|
context 'when not set' do
|
81
81
|
let(:configuration) { described_class.new }
|
82
|
-
it {
|
82
|
+
it { is_expected.to be_a Proc }
|
83
83
|
end
|
84
84
|
|
85
85
|
context 'when set' do
|
86
86
|
let(:configuration) { described_class.new(middlewares: setting) }
|
87
87
|
let(:setting) { proc { something } }
|
88
|
-
it {
|
88
|
+
it { is_expected.to eq setting }
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -94,13 +94,13 @@ describe StackerBee::Configuration do
|
|
94
94
|
|
95
95
|
context 'when not set' do
|
96
96
|
let(:configuration) { described_class.new }
|
97
|
-
it {
|
97
|
+
it { is_expected.to be_a Proc }
|
98
98
|
end
|
99
99
|
|
100
100
|
context 'when set' do
|
101
101
|
let(:configuration) { described_class.new(faraday_middlewares: setting) }
|
102
102
|
let(:setting) { proc { something } }
|
103
|
-
it {
|
103
|
+
it { is_expected.to eq setting }
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
@@ -132,24 +132,24 @@ describe StackerBee::Configuration do
|
|
132
132
|
context "when the child doesn't have an attribute set" do
|
133
133
|
let(:child) { described_class.new }
|
134
134
|
it 'uses the attribute of the parent' do
|
135
|
-
subject.url.
|
136
|
-
subject.api_key.
|
137
|
-
subject.secret_key.
|
138
|
-
subject.ssl_verify
|
139
|
-
subject.middlewares.
|
140
|
-
subject.faraday_middlewares.
|
135
|
+
expect(subject.url).to eq :parent_url
|
136
|
+
expect(subject.api_key).to eq :parent_api_key
|
137
|
+
expect(subject.secret_key).to eq :parent_secret_key
|
138
|
+
expect(subject.ssl_verify?).to eq :parent_ssl_verify
|
139
|
+
expect(subject.middlewares).to eq :parent_ssl_middlewares
|
140
|
+
expect(subject.faraday_middlewares).to eq :parent_faraday_middlewares
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
144
|
context "when the parent doesn't have an attribute set" do
|
145
145
|
let(:parent) { described_class.new }
|
146
146
|
it 'uses the attribute of the child' do
|
147
|
-
subject.url.
|
148
|
-
subject.api_key.
|
149
|
-
subject.secret_key.
|
150
|
-
subject.ssl_verify
|
151
|
-
subject.middlewares.
|
152
|
-
subject.faraday_middlewares.
|
147
|
+
expect(subject.url).to eq :child_url
|
148
|
+
expect(subject.api_key).to eq :child_api_key
|
149
|
+
expect(subject.secret_key).to eq :child_secret_key
|
150
|
+
expect(subject.ssl_verify?).to eq :child_ssl_verify
|
151
|
+
expect(subject.middlewares).to eq :child_ssl_middlewares
|
152
|
+
expect(subject.faraday_middlewares).to eq :child_faraday_middlewares
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
@@ -157,12 +157,12 @@ describe StackerBee::Configuration do
|
|
157
157
|
let(:child) { described_class.new }
|
158
158
|
let(:parent) { described_class.new }
|
159
159
|
it 'uses the defaults of the attributes of the child' do
|
160
|
-
subject.url.
|
161
|
-
subject.api_key.
|
162
|
-
subject.secret_key.
|
163
|
-
subject.ssl_verify
|
164
|
-
subject.middlewares.
|
165
|
-
subject.faraday_middlewares.
|
160
|
+
expect(subject.url).to eq nil
|
161
|
+
expect(subject.api_key).to eq nil
|
162
|
+
expect(subject.secret_key).to eq nil
|
163
|
+
expect(subject.ssl_verify?).to eq true
|
164
|
+
expect(subject.middlewares).to be_a Proc
|
165
|
+
expect(subject.faraday_middlewares).to be_a Proc
|
166
166
|
end
|
167
167
|
end
|
168
168
|
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe StackerBee::Connection do
|
4
4
|
subject(:get) { connection.get(path, query_params) }
|
5
|
-
before { Faraday.
|
5
|
+
before { allow(Faraday).to receive_messages new: faraday }
|
6
6
|
|
7
7
|
let(:url) { 'http://test.com:1234/foo/bar/' }
|
8
8
|
let(:path) { '/foo/bar' }
|
@@ -22,20 +22,27 @@ describe StackerBee::Connection do
|
|
22
22
|
|
23
23
|
context 'successfully connecting' do
|
24
24
|
before do
|
25
|
-
faraday.
|
25
|
+
expect(faraday).to receive(:get).with('/foo/bar', query_params) do
|
26
|
+
response
|
27
|
+
end
|
26
28
|
end
|
27
|
-
|
29
|
+
|
30
|
+
it { is_expected.to be response }
|
31
|
+
|
28
32
|
it 'specifies url without path when creating connection' do
|
29
33
|
get
|
30
|
-
Faraday.
|
31
|
-
|
34
|
+
expect(Faraday).to have_received(:new).with(url: 'http://test.com:1234',
|
35
|
+
ssl: { verify: true })
|
32
36
|
end
|
33
37
|
end
|
34
38
|
|
35
39
|
context 'failing to connect' do
|
36
40
|
before do
|
37
|
-
faraday.
|
41
|
+
allow(faraday).to receive(:get) do
|
42
|
+
fail Faraday::Error::ConnectionFailed, 'boom'
|
43
|
+
end
|
38
44
|
end
|
45
|
+
|
39
46
|
it 'raises a helpful exception' do
|
40
47
|
expect { get }.to raise_error StackerBee::ConnectionError, /#{url}/
|
41
48
|
end
|
@@ -60,8 +67,8 @@ describe StackerBee::Connection do
|
|
60
67
|
let(:ssl_verify) { false }
|
61
68
|
it 'specifies the ssl verify option when creating a connection' do
|
62
69
|
get
|
63
|
-
Faraday.
|
64
|
-
|
70
|
+
expect(Faraday).to have_received(:new).with(url: 'http://test.com:1234',
|
71
|
+
ssl: { verify: false })
|
65
72
|
end
|
66
73
|
end
|
67
74
|
end
|
@@ -27,28 +27,28 @@ describe StackerBee::Middleware::Adapter do
|
|
27
27
|
before { middleware.call(env) }
|
28
28
|
|
29
29
|
it 'makes a call via the connection' do
|
30
|
-
connection.
|
30
|
+
expect(connection).to have_received(:get)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "sets the environment's raw_response" do
|
34
|
-
env.raw_response.
|
34
|
+
expect(env.raw_response).to eq raw_response
|
35
35
|
end
|
36
36
|
|
37
37
|
it "sets the response's mime type" do
|
38
|
-
env.response.content_type.
|
38
|
+
expect(env.response.content_type).to eq content_type
|
39
39
|
end
|
40
40
|
|
41
41
|
it "sets the response's body to the raw response's body" do
|
42
|
-
env.response.body.
|
42
|
+
expect(env.response.body).to eq response_body
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'sorts the paramers' do
|
46
|
-
connection.
|
46
|
+
expect(connection).to have_received(:get).with(path, [%w(a a), %w(z z)])
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
describe '#endpoint_name_for' do
|
51
51
|
subject { middleware.endpoint_name_for('listVirtualMachines') }
|
52
|
-
it {
|
52
|
+
it { is_expected.to be_nil }
|
53
53
|
end
|
54
54
|
end
|
@@ -5,7 +5,7 @@ describe StackerBee::Middleware::Base do
|
|
5
5
|
let(:params) { {} }
|
6
6
|
let(:app) { double(:app, call: response) }
|
7
7
|
let(:response) { double(:response) }
|
8
|
-
let(:content_type) {
|
8
|
+
let(:content_type) { 'content-type' }
|
9
9
|
before { env.response.content_type = content_type }
|
10
10
|
|
11
11
|
let(:middleware) { subclass.new(app: app) }
|
@@ -20,7 +20,7 @@ describe StackerBee::Middleware::Base do
|
|
20
20
|
|
21
21
|
def self.it_calls_its_app_with_the_env
|
22
22
|
it 'calls its app with the env' do
|
23
|
-
app.
|
23
|
+
expect(app).to have_received(:call).with(env)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -38,7 +38,7 @@ describe StackerBee::Middleware::Base do
|
|
38
38
|
it_calls_its_app_with_the_env
|
39
39
|
|
40
40
|
it 'runs the before hook' do
|
41
|
-
env.before_was_run.
|
41
|
+
expect(env.before_was_run).to be true
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -54,7 +54,7 @@ describe StackerBee::Middleware::Base do
|
|
54
54
|
it_calls_its_app_with_the_env
|
55
55
|
|
56
56
|
it 'runs the after hook' do
|
57
|
-
env.after_was_run.
|
57
|
+
expect(env.after_was_run).to be true
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -76,14 +76,14 @@ describe StackerBee::Middleware::Base do
|
|
76
76
|
context 'when it matches the content type' do
|
77
77
|
let(:content_type) { 'text/html; uft-8' }
|
78
78
|
it 'runs the after hook' do
|
79
|
-
env.after_was_run.
|
79
|
+
expect(env.after_was_run).to be true
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
83
|
context "when it doesn't match the content type" do
|
84
84
|
let(:content_type) { 'text/javascript; uft-8' }
|
85
85
|
it 'runs the after hook' do
|
86
|
-
env.after_was_run.
|
86
|
+
expect(env.after_was_run).to be_nil
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
@@ -98,22 +98,22 @@ describe StackerBee::Middleware::Base do
|
|
98
98
|
end
|
99
99
|
|
100
100
|
it 'changes the params' do
|
101
|
-
env.request.params[:params_merged?].
|
101
|
+
expect(env.request.params[:params_merged?]).to be true
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
describe '#endpoint_name_for' do
|
107
|
-
let(:endpoint_name) {
|
108
|
-
let(:normalized_endpoint_name) {
|
107
|
+
let(:endpoint_name) { 'endpoint-name' }
|
108
|
+
let(:normalized_endpoint_name) { 'normalized-endpoint-name' }
|
109
109
|
|
110
110
|
it 'delegates to its app' do
|
111
|
-
app.
|
111
|
+
expect(app).to receive(:endpoint_name_for)
|
112
112
|
.with(endpoint_name)
|
113
113
|
.and_return(normalized_endpoint_name)
|
114
114
|
|
115
|
-
middleware.endpoint_name_for(endpoint_name)
|
116
|
-
.
|
115
|
+
expect(middleware.endpoint_name_for(endpoint_name))
|
116
|
+
.to eq normalized_endpoint_name
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
@@ -121,7 +121,7 @@ describe StackerBee::Middleware::Base do
|
|
121
121
|
describe 'by default' do
|
122
122
|
before { env.response.content_type = '$8^02(324' }
|
123
123
|
it 'matches anything' do
|
124
|
-
middleware.matches_content_type?(env).
|
124
|
+
expect(middleware.matches_content_type?(env)).to be true
|
125
125
|
end
|
126
126
|
end
|
127
127
|
end
|
@@ -13,11 +13,11 @@ describe StackerBee::Middleware::ConsoleAccess do
|
|
13
13
|
|
14
14
|
it 'adds its path to the env' do
|
15
15
|
middleware.before(env)
|
16
|
-
env.request.path.
|
16
|
+
expect(env.request.path).to eq described_class::PATH
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'adds cmd to the parameters' do
|
20
|
-
env.request.params.
|
20
|
+
expect(env.request.params).not_to include described_class::PARAMS
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -27,31 +27,31 @@ describe StackerBee::Middleware::ConsoleAccess do
|
|
27
27
|
before { middleware.before(env) }
|
28
28
|
|
29
29
|
it "doesn't add it's path" do
|
30
|
-
env.request.path.
|
30
|
+
expect(env.request.path).not_to eq described_class::PATH
|
31
31
|
end
|
32
32
|
|
33
33
|
it "doesn't add cmd to the parameters" do
|
34
|
-
env.request.params.
|
34
|
+
expect(env.request.params).not_to include described_class::PARAMS
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'matches html content typtes' do
|
39
|
-
middleware.content_types.
|
39
|
+
expect(middleware.content_types).to match 'text/html; charset=utf-8'
|
40
40
|
end
|
41
41
|
|
42
42
|
describe '#endpoint_name_for' do
|
43
43
|
context 'given names it reponds to' do
|
44
44
|
%w(consoleAccess console_access CONSOLEACCESS).each do |name|
|
45
45
|
subject { middleware.endpoint_name_for(name) }
|
46
|
-
it {
|
46
|
+
it { is_expected.to eq described_class::ENDPOINT }
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
context 'for other names' do
|
51
|
-
before { app.
|
51
|
+
before { allow(app).to receive :endpoint_name_for, &:upcase }
|
52
52
|
|
53
53
|
it 'delegates for other names' do
|
54
|
-
middleware.endpoint_name_for('other-name').
|
54
|
+
expect(middleware.endpoint_name_for('other-name')).to eq 'OTHER-NAME'
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -8,12 +8,12 @@ describe StackerBee::Middleware::DictionaryFlattener do
|
|
8
8
|
|
9
9
|
describe '.detokenize' do
|
10
10
|
subject { described_class.detokenize(tokenized_string) }
|
11
|
-
it {
|
11
|
+
it { is_expected.to eq string }
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '.tokenize' do
|
15
15
|
subject { described_class.tokenize(string) }
|
16
|
-
it {
|
16
|
+
it { is_expected.to eq tokenized_string }
|
17
17
|
end
|
18
18
|
|
19
19
|
describe '.new' do
|
@@ -34,28 +34,28 @@ describe StackerBee::Middleware::DictionaryFlattener do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'flattens objects in the manner that cloudstack expects' do
|
37
|
-
subject["#{param(0)}.name"].
|
38
|
-
subject["#{param(0)}.key"].
|
39
|
-
subject["#{param(0)}.value"].
|
37
|
+
expect(subject["#{param(0)}.name"]).to eq 'r2'
|
38
|
+
expect(subject["#{param(0)}.key"]).to eq 'r2'
|
39
|
+
expect(subject["#{param(0)}.value"]).to eq 'd2'
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'does not flatten empty hashes' do
|
43
|
-
subject.
|
43
|
+
expect(subject).not_to have_key "#{param(2)}.name"
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'handles true booleans' do
|
47
|
-
subject["#{param(1)}.name"].
|
48
|
-
subject["#{param(1)}.value"].
|
47
|
+
expect(subject["#{param(1)}.name"]).to eq 'droid'
|
48
|
+
expect(subject["#{param(1)}.value"]).to be true
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'removes original map params' do
|
52
|
-
subject.
|
52
|
+
expect(subject).not_to have_key 'rebels'
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'doesnt send false to CloudStack' do
|
56
56
|
# This assumption is based on CloudStack UI behavior
|
57
|
-
subject.values.
|
58
|
-
subject.values.
|
57
|
+
expect(subject.values).not_to include false
|
58
|
+
expect(subject.values).not_to include 'false'
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
@@ -13,19 +13,19 @@ describe StackerBee::Middleware::EndpointNormalizer do
|
|
13
13
|
let(:endpoint_name) { :some_endpoint }
|
14
14
|
|
15
15
|
describe '#endpoint_name_for' do
|
16
|
-
before { app.
|
16
|
+
before { allow(app).to receive :endpoint_name_for, &:upcase }
|
17
17
|
|
18
18
|
it 'delegates to its app' do
|
19
|
-
middleware.endpoint_name_for('some-name').
|
19
|
+
expect(middleware.endpoint_name_for('some-name')).to eq 'SOME-NAME'
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
describe '#before' do
|
24
|
-
before { app.
|
24
|
+
before { allow(app).to receive_messages endpoint_name_for: nil }
|
25
25
|
|
26
26
|
it "doesn't set the endpoint to nil", :regression do
|
27
27
|
middleware.before env
|
28
|
-
env.request.endpoint_name.
|
28
|
+
expect(env.request.endpoint_name).to eq endpoint_name
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -16,10 +16,10 @@ describe StackerBee::Middleware::ErrorMessage do
|
|
16
16
|
let(:is_success?) { true }
|
17
17
|
|
18
18
|
it "doesn't apply to HTML responses" do
|
19
|
-
middleware.content_types.
|
19
|
+
expect(middleware.content_types).not_to match 'text/html; charset=utf-8'
|
20
20
|
end
|
21
21
|
it 'applies to JSON responses' do
|
22
|
-
middleware.content_types.
|
22
|
+
expect(middleware.content_types).to match 'text/javascript; charset=utf-8'
|
23
23
|
end
|
24
24
|
|
25
25
|
context 'given an error' do
|
@@ -10,9 +10,9 @@ describe StackerBee::Middleware::FormatKeys do
|
|
10
10
|
}
|
11
11
|
end
|
12
12
|
|
13
|
-
it {
|
14
|
-
it {
|
13
|
+
it { is_expected.to have_key 'symbol' }
|
14
|
+
it { is_expected.not_to have_key :symbol }
|
15
15
|
|
16
|
-
it {
|
17
|
-
it {
|
16
|
+
it { is_expected.to have_key 'keyCase' }
|
17
|
+
it { is_expected.not_to have_key :key_case }
|
18
18
|
end
|
@@ -18,7 +18,7 @@ describe StackerBee::Middleware::HTTPStatus do
|
|
18
18
|
let(:success?) { false }
|
19
19
|
|
20
20
|
its(:status) { should eq http_status }
|
21
|
-
it {
|
21
|
+
it { is_expected.not_to be_success }
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'given a success' do
|
@@ -26,6 +26,6 @@ describe StackerBee::Middleware::HTTPStatus do
|
|
26
26
|
let(:success?) { true }
|
27
27
|
|
28
28
|
its(:status) { should eq http_status }
|
29
|
-
it {
|
29
|
+
it { is_expected.to be_success }
|
30
30
|
end
|
31
31
|
end
|
@@ -13,10 +13,10 @@ describe StackerBee::Middleware::LogResponse do
|
|
13
13
|
|
14
14
|
shared_examples_for 'all logs' do
|
15
15
|
it 'logs the details' do
|
16
|
-
logger.logs.length.
|
17
|
-
logger.logs.last[:request_path].
|
18
|
-
logger.logs.last[:params].
|
19
|
-
logger.logs.last[:response_body].
|
16
|
+
expect(logger.logs.length).to eq 1
|
17
|
+
expect(logger.logs.last[:request_path]).to eq env.request.path
|
18
|
+
expect(logger.logs.last[:params]).to eq env.request.params.to_a
|
19
|
+
expect(logger.logs.last[:response_body]).to eq env.raw_response[:body]
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -29,7 +29,7 @@ describe StackerBee::Middleware::LogResponse do
|
|
29
29
|
|
30
30
|
it_should_behave_like 'all logs'
|
31
31
|
it 'should have logged the details' do
|
32
|
-
logger.logs.last[:short_message].
|
32
|
+
expect(logger.logs.last[:short_message]).to eq \
|
33
33
|
'some command failed: invalid request'
|
34
34
|
end
|
35
35
|
end
|
@@ -42,8 +42,8 @@ describe StackerBee::Middleware::LogResponse do
|
|
42
42
|
|
43
43
|
it_should_behave_like 'all logs'
|
44
44
|
it 'should have logged the details' do
|
45
|
-
logger.logs.length.
|
46
|
-
logger.logs.last[:short_message].
|
45
|
+
expect(logger.logs.length).to eq 1
|
46
|
+
expect(logger.logs.last[:short_message]).to eq 'some command'
|
47
47
|
end
|
48
48
|
|
49
49
|
end
|
@@ -41,14 +41,16 @@ describe StackerBee::Middleware::RemoveEmptyStrings do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'removes empty strings from the input' do
|
44
|
-
params.keys.
|
44
|
+
expect(params.keys).to match_array [:ok1, :ok2, :ok3, :ok4, :nested]
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'removes empty strings nested in hashes' do
|
48
|
-
params[:nested].keys.
|
48
|
+
expect(params[:nested].keys).to match_array \
|
49
|
+
[:ok1, :ok2, :ok3, :ok4, :nested]
|
49
50
|
end
|
50
51
|
|
51
52
|
it 'removes empty strings deeply nested in hashes' do
|
52
|
-
params[:nested][:nested].keys.
|
53
|
+
expect(params[:nested][:nested].keys).to match_array \
|
54
|
+
[:ok1, :ok2, :ok3, :ok4]
|
53
55
|
end
|
54
56
|
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe StackerBee::Middleware::RemoveNils do
|
4
4
|
it 'removes pairs with nil values from the params' do
|
5
|
-
subject.transform_params(something: 'something', nothing: nil)
|
6
|
-
.
|
5
|
+
expect(subject.transform_params(something: 'something', nothing: nil))
|
6
|
+
.to eq something: 'something'
|
7
7
|
end
|
8
8
|
end
|
@@ -32,14 +32,14 @@ describe StackerBee::Rash do
|
|
32
32
|
let(:dissimilar_hash) { hash.dup.tap { |loud| loud.delete 'foo' } }
|
33
33
|
let(:rash) { described_class.new(hash) }
|
34
34
|
|
35
|
-
it {
|
35
|
+
it { is_expected.to include 'FOO' }
|
36
36
|
|
37
|
-
it {
|
38
|
-
it {
|
39
|
-
it {
|
40
|
-
it {
|
41
|
-
it {
|
42
|
-
it {
|
37
|
+
it { is_expected.to eq subject }
|
38
|
+
it { is_expected.to eq subject.dup }
|
39
|
+
it { is_expected.to eq hash }
|
40
|
+
it { is_expected.to eq described_class.new(hash) }
|
41
|
+
it { is_expected.to eq similar_hash }
|
42
|
+
it { is_expected.not_to eq dissimilar_hash }
|
43
43
|
|
44
44
|
it_behaves_like 'a Rash',
|
45
45
|
'FOO' => 'foo',
|
@@ -68,20 +68,20 @@ describe StackerBee::Rash do
|
|
68
68
|
|
69
69
|
describe '#select' do
|
70
70
|
subject { rash.select { |_, value| value.is_a? String } }
|
71
|
-
it {
|
72
|
-
it {
|
73
|
-
it {
|
71
|
+
it { is_expected.to be_a described_class }
|
72
|
+
it { is_expected.to include 'FOO' }
|
73
|
+
it { is_expected.not_to include 'WIZ' }
|
74
74
|
end
|
75
75
|
|
76
76
|
describe '#reject' do
|
77
77
|
subject { rash.reject { |_, value| value.is_a? String } }
|
78
|
-
it {
|
79
|
-
it {
|
80
|
-
it {
|
78
|
+
it { is_expected.to be_a described_class }
|
79
|
+
it { is_expected.to include 'WIZ' }
|
80
|
+
it { is_expected.not_to include 'FOO' }
|
81
81
|
end
|
82
82
|
|
83
83
|
describe '#values_at' do
|
84
84
|
subject { rash.values_at 'FOO', 'WIZ', 'WRONG' }
|
85
|
-
it {
|
85
|
+
it { is_expected.to eq ['foo', wiz, nil] }
|
86
86
|
end
|
87
87
|
end
|
@@ -11,15 +11,15 @@ describe 'An error occuring' do
|
|
11
11
|
|
12
12
|
context 'HTTP status in the 400s' do
|
13
13
|
let(:status) { 431 }
|
14
|
-
it {
|
14
|
+
it { is_expected.to be_a StackerBee::ClientError }
|
15
15
|
end
|
16
16
|
context 'HTTP status in the 500s' do
|
17
17
|
let(:status) { 500 }
|
18
|
-
it {
|
18
|
+
it { is_expected.to be_a StackerBee::ServerError }
|
19
19
|
end
|
20
20
|
context 'HTTP status > 599' do
|
21
21
|
let(:status) { 999 }
|
22
|
-
it {
|
22
|
+
it { is_expected.to be_a StackerBee::RequestError }
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -3,28 +3,28 @@ require 'spec_helper'
|
|
3
3
|
describe StackerBee::Utilities, '#uncase' do
|
4
4
|
include StackerBee::Utilities
|
5
5
|
|
6
|
-
it { uncase('Foo Bar').
|
7
|
-
it { uncase('foo_bar').
|
8
|
-
it { uncase('foo-bar').
|
9
|
-
it { uncase('fooBar').
|
10
|
-
it { uncase('foo[0].Bar').
|
11
|
-
|
12
|
-
it { snake_case('Foo Bar').
|
13
|
-
it { snake_case('foo_bar').
|
14
|
-
it { snake_case('foo-bar').
|
15
|
-
it { snake_case('fooBar').
|
16
|
-
|
17
|
-
it { camel_case('Foo Bar').
|
18
|
-
it { camel_case('foo_bar').
|
19
|
-
it { camel_case('foo-bar').
|
20
|
-
it { camel_case('fooBar').
|
21
|
-
|
22
|
-
it { camel_case('Foo Bar', true).
|
23
|
-
it { camel_case('foo_bar', true).
|
24
|
-
it { camel_case('foo-bar', true).
|
25
|
-
it { camel_case('fooBar', true).
|
26
|
-
it { camel_case('fooBar', false).
|
27
|
-
it { camel_case('foo[0].Bar', false).
|
6
|
+
it { expect(uncase('Foo Bar')).to eq 'foobar' }
|
7
|
+
it { expect(uncase('foo_bar')).to eq 'foobar' }
|
8
|
+
it { expect(uncase('foo-bar')).to eq 'foobar' }
|
9
|
+
it { expect(uncase('fooBar')).to eq 'foobar' }
|
10
|
+
it { expect(uncase('foo[0].Bar')).to eq 'foo[0].bar' }
|
11
|
+
|
12
|
+
it { expect(snake_case('Foo Bar')).to eq 'foo_bar' }
|
13
|
+
it { expect(snake_case('foo_bar')).to eq 'foo_bar' }
|
14
|
+
it { expect(snake_case('foo-bar')).to eq 'foo_bar' }
|
15
|
+
it { expect(snake_case('fooBar')).to eq 'foo_bar' }
|
16
|
+
|
17
|
+
it { expect(camel_case('Foo Bar')).to eq 'FooBar' }
|
18
|
+
it { expect(camel_case('foo_bar')).to eq 'FooBar' }
|
19
|
+
it { expect(camel_case('foo-bar')).to eq 'FooBar' }
|
20
|
+
it { expect(camel_case('fooBar')).to eq 'FooBar' }
|
21
|
+
|
22
|
+
it { expect(camel_case('Foo Bar', true)).to eq 'fooBar' }
|
23
|
+
it { expect(camel_case('foo_bar', true)).to eq 'fooBar' }
|
24
|
+
it { expect(camel_case('foo-bar', true)).to eq 'fooBar' }
|
25
|
+
it { expect(camel_case('fooBar', true)).to eq 'fooBar' }
|
26
|
+
it { expect(camel_case('fooBar', false)).to eq 'FooBar' }
|
27
|
+
it { expect(camel_case('foo[0].Bar', false)).to eq 'Foo[0].Bar' }
|
28
28
|
|
29
29
|
describe '#map_a_hash' do
|
30
30
|
let(:original) { { 1 => 1, 2 => 2 } }
|
@@ -35,7 +35,7 @@ describe StackerBee::Utilities, '#uncase' do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'maps over a hash' do
|
38
|
-
transformed.
|
38
|
+
expect(transformed).to eq expected
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'does not modify the original' do
|
@@ -45,10 +45,10 @@ describe StackerBee::Utilities, '#uncase' do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
describe '.transform_hash_keys' do
|
48
|
-
it { transform_hash_keys({ 1 => 2 }, &:odd?).
|
48
|
+
it { expect(transform_hash_keys({ 1 => 2 }, &:odd?)).to eq true => 2 }
|
49
49
|
end
|
50
50
|
|
51
51
|
describe '.transform_hash_values' do
|
52
|
-
it { transform_hash_values({ 1 => 2 }, &:odd?).
|
52
|
+
it { expect(transform_hash_values({ 1 => 2 }, &:odd?)).to eq 1 => false }
|
53
53
|
end
|
54
54
|
end
|
data/stacker_bee.gemspec
CHANGED
@@ -25,11 +25,12 @@ Gem::Specification.new do |spec|
|
|
25
25
|
# this is a dependency for FaradayMiddleware::Graylog
|
26
26
|
spec.add_runtime_dependency 'faraday_middleware', '~> 0.9'
|
27
27
|
|
28
|
-
spec.add_development_dependency 'bundler',
|
29
|
-
spec.add_development_dependency 'rake',
|
30
|
-
spec.add_development_dependency 'rspec',
|
31
|
-
spec.add_development_dependency '
|
32
|
-
spec.add_development_dependency '
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
29
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.0.0'
|
31
|
+
spec.add_development_dependency 'rspec-its', '~> 1.0'
|
32
|
+
spec.add_development_dependency 'webmock', '~> 1.15'
|
33
|
+
spec.add_development_dependency 'vcr', '~> 2.9'
|
33
34
|
spec.add_development_dependency 'pry'
|
34
35
|
|
35
36
|
# It should be consistent for Travis and all developers, since we don't check
|
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.1.
|
4
|
+
version: 2.1.1.pre265
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Sterndale
|
@@ -93,14 +93,28 @@ dependencies:
|
|
93
93
|
requirements:
|
94
94
|
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 3.0.0
|
97
97
|
type: :development
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 3.0.0
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: rspec-its
|
106
|
+
requirement: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.0'
|
111
|
+
type: :development
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.0'
|
104
118
|
- !ruby/object:Gem::Dependency
|
105
119
|
name: webmock
|
106
120
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,14 +135,14 @@ dependencies:
|
|
121
135
|
requirements:
|
122
136
|
- - ~>
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: '2.
|
138
|
+
version: '2.9'
|
125
139
|
type: :development
|
126
140
|
prerelease: false
|
127
141
|
version_requirements: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
143
|
- - ~>
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version: '2.
|
145
|
+
version: '2.9'
|
132
146
|
- !ruby/object:Gem::Dependency
|
133
147
|
name: pry
|
134
148
|
requirement: !ruby/object:Gem::Requirement
|