vagrant-arubacloud 0.0.7 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,185 +1,185 @@
1
- require 'spec_helper'
2
- require 'vagrant-arubacloud/config'
3
- require 'fog/arubacloud'
4
- require 'vagrant'
5
-
6
- RSpec.describe VagrantPlugins::ArubaCloud::Config do
7
- describe 'defaults' do
8
-
9
- subject do
10
- super().tap do |o|
11
- o.finalize!
12
- end
13
- end
14
-
15
- it :arubacloud_username do
16
- subject.expect(:arubacloud_username).to be_nil
17
- end
18
- it :arubacloud_password do
19
- subject.expect(:arubacloud_password).to be_nil
20
- end
21
- it :url do
22
- subject.expect(:url).to be_nil
23
- end
24
- it :endpoint do
25
- subject.expect(:endpoint).to be_nil
26
- end
27
- it :server_name do
28
- subject.expect(:server_name).to be_nil
29
- end
30
- it :template_id do
31
- subject.expect(:template_id).to be_nil
32
- end
33
- it :package_id do
34
- subject.expect(:package_id).to be_nil
35
- end
36
-
37
- describe 'overriding default' do
38
- [:arubacloud_username,
39
- :arubacloud_password,
40
- :url,
41
- :endpoint,
42
- :server_name,
43
- :template_id,
44
- :package_id].each do |attribute|
45
- it "should not default #{attribute} if overridden" do
46
- subject.send("#{attribute}=".to_sym, 'foo')
47
- subject.finalize!
48
- subject.expect("#{attribute}").to eq('foo')
49
- end
50
- end
51
- end
52
-
53
- subject do
54
- super().tap do |o|
55
- o.finalize!
56
- end
57
- end
58
-
59
- describe 'validation' do
60
- let(:machine) { double('machine') }
61
- let(:validation_errors) { subject.validate(machine)['ArubaCloud Provider'] }
62
- let(:error_message) { double('error message') }
63
-
64
- # prepare the subject with all expected properties
65
- before(:each) do
66
- allow(machine).to receive_message_chain(:env, :root_path) { '/' }
67
- allow(machine).to receive_message_chain("config.ssh.password") { "pussysecret" }
68
- subject.arubacloud_username = 'foo'
69
- subject.arubacloud_password = 'bar'
70
- subject.template_id = 1
71
- subject.package_id = 'small'
72
- subject.service_type = 1
73
- subject.cpu_number = 1
74
- subject.ram_qty = 1
75
- subject.hds = [{:type => 1, :size => 50}]
76
- end
77
-
78
- subject do
79
- super().tap do |o|
80
- o.finalize!
81
- end
82
- end
83
-
84
- context 'with good values' do
85
- it "arubacloud_username" do
86
- expect(validation_errors).to be_empty
87
- end
88
- end
89
-
90
- context 'with invalid key' do
91
- it 'should raise an error' do
92
- subject.nonsense1 = true
93
- subject.nonsense2 = false
94
- expect(I18n).to receive(:t).with('vagrant.config.common.bad_field', { :fields => 'nonsense1, nonsense2' }).and_return error_message
95
- validation_errors.first == error_message
96
- end
97
- end
98
-
99
- context 'the arubacloud_username' do
100
- it 'should error if not given' do
101
- subject.arubacloud_username = nil
102
- expect(I18n).to receive(:t).with('vagrant_arubacloud.config.arubacloud_username_required').and_return :error_message
103
- validation_errors.first == error_message
104
- end
105
- end
106
-
107
- context 'the arubacloud_password' do
108
- it 'should error if not given' do
109
- subject.arubacloud_password = nil
110
- expect(I18n).to receive(:t).with('vagrant_arubacloud.config.arubacloud_password_required').and_return error_message
111
- validation_errors.first == error_message
112
- end
113
- end
114
-
115
- context 'the template_id' do
116
- it 'should error if not given' do
117
- subject.template_id = nil
118
- expect(I18n).to receive(:t).with('vagrant_arubacloud.config.template_id_required').and_return error_message
119
- validation_errors.first == error_message
120
- end
121
- end
122
-
123
- context 'the service_type' do
124
- it 'should error if not given' do
125
- subject.service_type = nil
126
- expect(I18n).to receive(:t).with('vagrant_arubacloud.config.service_type_required').and_return error_message
127
- validation_errors.first == error_message
128
- end
129
- end
130
-
131
- describe 'smart create' do
132
- context 'the package_id' do
133
- it 'should error if not given' do
134
- subject.package_id = nil
135
- subject.service_type = 4
136
- expect(I18n).to receive(:t).with('vagrant_arubacloud.config.package_id_required').and_return error_message
137
- validation_errors.first == error_message
138
- end
139
- end
140
- end
141
-
142
- describe 'pro create' do
143
- before(:each) do
144
- subject.service_type = 1
145
- end
146
-
147
- context 'the cpu_number' do
148
- it 'should error if not given' do
149
- subject.cpu_number = nil
150
- expect(I18n).to receive(:t).with('vagrant_arubacloud.config.cpu_number_required').and_return error_message
151
- validation_errors.first == error_message
152
- end
153
- end
154
- context 'the ram_qty' do
155
- it 'should error if not given' do
156
- subject.ram_qty = nil
157
- expect(I18n).to receive(:t).with('vagrant_arubacloud.config.ram_qty_required').and_return error_message
158
- validation_errors.first == error_message
159
- end
160
- end
161
- context 'the package_id' do
162
- it 'should valid if not given' do
163
- subject.package_id = nil
164
- expect(validation_errors).to be_empty
165
- end
166
- end
167
- context 'the hds configuration' do
168
- it 'should error if its not an array' do
169
- subject.hds = 'test'
170
- expect(I18n).to receive(:t).with('vagrant_arubacloud.config.hds_conf_must_be_array').and_return error_message
171
- validation_errors.first == error_message
172
- end
173
- end
174
- context 'the hds configuration' do
175
- it 'should error if not given' do
176
- subject.hds = nil
177
- expect(I18n).to receive(:t).with('vagrant_arubacloud.config.hds_conf_required').and_return error_message
178
- validation_errors.first == error_message
179
- end
180
- end
181
- end
182
- end
183
- end
184
- end
185
-
1
+ require 'spec_helper'
2
+ require 'vagrant-arubacloud/config'
3
+ require 'fog/arubacloud'
4
+ require 'vagrant'
5
+
6
+ RSpec.describe VagrantPlugins::ArubaCloud::Config do
7
+ describe 'defaults' do
8
+
9
+ subject do
10
+ super().tap do |o|
11
+ o.finalize!
12
+ end
13
+ end
14
+
15
+ it :arubacloud_username do
16
+ subject.expect(:arubacloud_username).to be_nil
17
+ end
18
+ it :arubacloud_password do
19
+ subject.expect(:arubacloud_password).to be_nil
20
+ end
21
+ it :url do
22
+ subject.expect(:url).to be_nil
23
+ end
24
+ it :endpoint do
25
+ subject.expect(:endpoint).to be_nil
26
+ end
27
+ it :server_name do
28
+ subject.expect(:server_name).to be_nil
29
+ end
30
+ it :template_id do
31
+ subject.expect(:template_id).to be_nil
32
+ end
33
+ it :package_id do
34
+ subject.expect(:package_id).to be_nil
35
+ end
36
+
37
+ describe 'overriding default' do
38
+ [:arubacloud_username,
39
+ :arubacloud_password,
40
+ :url,
41
+ :endpoint,
42
+ :server_name,
43
+ :template_id,
44
+ :package_id].each do |attribute|
45
+ it "should not default #{attribute} if overridden" do
46
+ subject.send("#{attribute}=".to_sym, 'foo')
47
+ subject.finalize!
48
+ subject.expect("#{attribute}").to eq('foo')
49
+ end
50
+ end
51
+ end
52
+
53
+ subject do
54
+ super().tap do |o|
55
+ o.finalize!
56
+ end
57
+ end
58
+
59
+ describe 'validation' do
60
+ let(:machine) { double('machine') }
61
+ let(:validation_errors) { subject.validate(machine)['ArubaCloud Provider'] }
62
+ let(:error_message) { double('error message') }
63
+
64
+ # prepare the subject with all expected properties
65
+ before(:each) do
66
+ allow(machine).to receive_message_chain(:env, :root_path) { '/' }
67
+ allow(machine).to receive_message_chain("config.ssh.password") { "pussysecret" }
68
+ subject.arubacloud_username = 'foo'
69
+ subject.arubacloud_password = 'bar'
70
+ subject.template_id = 1
71
+ subject.package_id = 'small'
72
+ subject.service_type = 1
73
+ subject.cpu_number = 1
74
+ subject.ram_qty = 1
75
+ subject.hds = [{:type => 1, :size => 50}]
76
+ end
77
+
78
+ subject do
79
+ super().tap do |o|
80
+ o.finalize!
81
+ end
82
+ end
83
+
84
+ context 'with good values' do
85
+ it "arubacloud_username" do
86
+ expect(validation_errors).to be_empty
87
+ end
88
+ end
89
+
90
+ context 'with invalid key' do
91
+ it 'should raise an error' do
92
+ subject.nonsense1 = true
93
+ subject.nonsense2 = false
94
+ expect(I18n).to receive(:t).with('vagrant.config.common.bad_field', { :fields => 'nonsense1, nonsense2' }).and_return error_message
95
+ validation_errors.first == error_message
96
+ end
97
+ end
98
+
99
+ context 'the arubacloud_username' do
100
+ it 'should error if not given' do
101
+ subject.arubacloud_username = nil
102
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.arubacloud_username_required').and_return :error_message
103
+ validation_errors.first == error_message
104
+ end
105
+ end
106
+
107
+ context 'the arubacloud_password' do
108
+ it 'should error if not given' do
109
+ subject.arubacloud_password = nil
110
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.arubacloud_password_required').and_return error_message
111
+ validation_errors.first == error_message
112
+ end
113
+ end
114
+
115
+ context 'the template_id' do
116
+ it 'should error if not given' do
117
+ subject.template_id = nil
118
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.template_id_required').and_return error_message
119
+ validation_errors.first == error_message
120
+ end
121
+ end
122
+
123
+ context 'the service_type' do
124
+ it 'should error if not given' do
125
+ subject.service_type = nil
126
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.service_type_required').and_return error_message
127
+ validation_errors.first == error_message
128
+ end
129
+ end
130
+
131
+ describe 'smart create' do
132
+ context 'the package_id' do
133
+ it 'should error if not given' do
134
+ subject.package_id = nil
135
+ subject.service_type = 4
136
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.package_id_required').and_return error_message
137
+ validation_errors.first == error_message
138
+ end
139
+ end
140
+ end
141
+
142
+ describe 'pro create' do
143
+ before(:each) do
144
+ subject.service_type = 1
145
+ end
146
+
147
+ context 'the cpu_number' do
148
+ it 'should error if not given' do
149
+ subject.cpu_number = nil
150
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.cpu_number_required').and_return error_message
151
+ validation_errors.first == error_message
152
+ end
153
+ end
154
+ context 'the ram_qty' do
155
+ it 'should error if not given' do
156
+ subject.ram_qty = nil
157
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.ram_qty_required').and_return error_message
158
+ validation_errors.first == error_message
159
+ end
160
+ end
161
+ context 'the package_id' do
162
+ it 'should valid if not given' do
163
+ subject.package_id = nil
164
+ expect(validation_errors).to be_empty
165
+ end
166
+ end
167
+ context 'the hds configuration' do
168
+ it 'should error if its not an array' do
169
+ subject.hds = 'test'
170
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.hds_conf_must_be_array').and_return error_message
171
+ validation_errors.first == error_message
172
+ end
173
+ end
174
+ context 'the hds configuration' do
175
+ it 'should error if not given' do
176
+ subject.hds = nil
177
+ expect(I18n).to receive(:t).with('vagrant_arubacloud.config.hds_conf_required').and_return error_message
178
+ validation_errors.first == error_message
179
+ end
180
+ end
181
+ end
182
+ end
183
+ end
184
+ end
185
+
@@ -1,27 +1,26 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
-
5
- require 'vagrant-arubacloud/version'
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = 'vagrant-arubacloud'
9
- spec.version = Vagrant::ArubaCloud::VERSION
10
- spec.authors = ['Aruba S.p.A.']
11
- spec.email = ['cloudsdk@staff.aruba.it']
12
- spec.summary = %q{Enables Vagrant to manage servers in ArubaCloud IaaS.}
13
- spec.description = %q{Enables Vagrant to manage servers in ArubaCloud IaaS; this version support 'reload' and 'snapshot' option}
14
- spec.homepage = 'https://www.github.com/arubacloud/vagrant-arubacloud'
15
- spec.license = 'MIT'
16
-
17
- spec.add_runtime_dependency 'fog', '~> 1.22'
18
- spec.add_runtime_dependency 'fog-arubacloud', '~> 0.0', '>= 0.0.6'
19
- spec.add_development_dependency 'bundler', '~> 1.7'
20
- spec.add_development_dependency 'rake' , '~> 12.3'
21
- spec.add_development_dependency 'rspec', '~> 3.7'
22
-
23
- spec.files = `git ls-files -z`.split("\x0")
24
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
25
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
26
- spec.require_paths = ['lib']
27
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'vagrant-arubacloud/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'vagrant-arubacloud'
9
+ spec.version = Vagrant::ArubaCloud::VERSION
10
+ spec.authors = ['Aruba S.p.A.']
11
+ spec.email = ['cloudsdk@staff.aruba.it']
12
+ spec.summary = %q{Enables Vagrant to manage servers in ArubaCloud IaaS.}
13
+ spec.description = %q{Enables Vagrant to manage servers in ArubaCloud IaaS; this version support 'reload' and 'snapshot' option}
14
+ spec.homepage = 'https://www.github.com/arubacloud/vagrant-arubacloud'
15
+ spec.license = 'MIT'
16
+
17
+ spec.add_runtime_dependency 'fog-arubacloud', '~> 0.0', '>= 0.0.6'
18
+ spec.add_development_dependency 'bundler', '~> 1.7'
19
+ spec.add_development_dependency 'rake' , '~> 12.3'
20
+ spec.add_development_dependency 'rspec', '~> 3.7'
21
+
22
+ spec.files = `git ls-files -z`.split("\x0")
23
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
+ spec.require_paths = ['lib']
26
+ end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-arubacloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aruba S.p.A.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-06 00:00:00.000000000 Z
11
+ date: 2018-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: fog
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.22'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.22'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: fog-arubacloud
29
15
  requirement: !ruby/object:Gem::Requirement