knife-ec2 0.13.0 → 0.14.0

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.
@@ -1,131 +1,131 @@
1
- # License:: Apache License, Version 2.0
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
-
16
- require File.expand_path('../../spec_helper', __FILE__)
17
- require 'fog/aws'
18
-
19
- describe Chef::Knife::Ec2ServerList do
20
-
21
- describe '#run' do
22
- let(:knife_ec2_list) { Chef::Knife::Ec2ServerList.new }
23
- let(:ec2_connection) { double(Fog::Compute::AWS) }
24
- before do
25
- allow(knife_ec2_list).to receive(:connection).and_return(ec2_connection)
26
- end
27
-
28
- it 'invokes validate!' do
29
- ec2_servers = double()
30
- allow(ec2_connection).to receive(:servers).and_return(ec2_servers)
31
- allow(knife_ec2_list.ui).to receive(:warn)
32
- expect(knife_ec2_list).to receive(:validate!)
33
- knife_ec2_list.run
34
- end
35
-
36
- context 'when region is not specified' do
37
- it 'shows warning that default region will be will be used' do
38
- knife_ec2_list.config.delete(:region)
39
- Chef::Config[:knife].delete(:region)
40
- ec2_servers = double()
41
- allow(ec2_connection).to receive(:servers).and_return(ec2_servers)
42
- allow(knife_ec2_list).to receive(:validate!)
43
- expect(knife_ec2_list.ui).to receive(:warn).with("No region was specified in knife.rb or as an argument. The default region, us-east-1, will be used:")
44
- knife_ec2_list.run
45
- end
46
- end
47
-
48
- context '--format option' do
49
- context 'when format=summary' do
50
- before do
51
- knife_ec2_list.config[:format] = 'summary'
52
- allow(knife_ec2_list.ui).to receive(:warn)
53
- end
54
-
55
- it 'shows the output without Tags and Availability Zone in summary format' do
56
- output_column = ["Instance ID", "Public IP", "Private IP", "Flavor",
57
- "Image", "SSH Key", "Security Groups", "IAM Profile", "State"]
58
- output_column_count = output_column.length
59
- allow(ec2_connection).to receive(:servers).and_return([])
60
- allow(knife_ec2_list).to receive(:validate!)
61
- expect(knife_ec2_list.ui).to receive(:list).with(output_column,:uneven_columns_across, output_column_count)
62
- knife_ec2_list.run
63
- end
64
- end
65
-
66
- context 'when format=json' do
67
- before do
68
- knife_ec2_list.config[:format] = 'json'
69
- allow(knife_ec2_list.ui).to receive(:warn)
70
- end
71
-
72
- it 'shows the output without Tags and Availability Zone in summary format' do
73
- allow(ec2_connection).to receive(:servers).and_return([])
74
- allow(knife_ec2_list).to receive(:validate!)
75
- allow(knife_ec2_list).to receive(:format_for_display)
76
- expect(knife_ec2_list).to receive(:output)
77
- knife_ec2_list.run
78
- end
79
- end
80
- end
81
-
82
- context 'when --tags option is passed' do
83
- before do
84
- knife_ec2_list.config[:format] = 'summary'
85
- allow(knife_ec2_list.ui).to receive(:warn)
86
- allow(ec2_connection).to receive(:servers).and_return([])
87
- allow(knife_ec2_list).to receive(:validate!)
88
- end
89
-
90
- context 'when single tag is passed' do
91
- it 'shows single tag field in the output' do
92
- knife_ec2_list.config[:tags] = 'tag1'
93
- output_column = ["Instance ID", "Public IP", "Private IP", "Flavor",
94
- "Image", "SSH Key", "Security Groups", "Tag:tag1", "IAM Profile", "State"]
95
- output_column_count = output_column.length
96
- expect(knife_ec2_list.ui).to receive(:list).with(output_column,:uneven_columns_across, output_column_count)
97
- knife_ec2_list.run
98
- end
99
- end
100
-
101
- context 'when multiple tags are passed' do
102
- it 'shows multiple tags fields in the output' do
103
- knife_ec2_list.config[:tags] = 'tag1,tag2'
104
- output_column = ["Instance ID", "Public IP", "Private IP", "Flavor",
105
- "Image", "SSH Key", "Security Groups", "Tag:tag1", "Tag:tag2", "IAM Profile", "State"]
106
- output_column_count = output_column.length
107
- expect(knife_ec2_list.ui).to receive(:list).with(output_column,:uneven_columns_across, output_column_count)
108
- knife_ec2_list.run
109
- end
110
- end
111
- end
112
-
113
- context 'when --availability-zone is passed' do
114
- before do
115
- knife_ec2_list.config[:format] = 'summary'
116
- allow(knife_ec2_list.ui).to receive(:warn)
117
- allow(ec2_connection).to receive(:servers).and_return([])
118
- allow(knife_ec2_list).to receive(:validate!)
119
- end
120
-
121
- it 'shows the availability zones in the output' do
122
- knife_ec2_list.config[:az] = true
123
- output_column = ["Instance ID", "Public IP", "Private IP", "Flavor", "AZ",
124
- "Image", "SSH Key", "Security Groups", "IAM Profile", "State"]
125
- output_column_count = output_column.length
126
- expect(knife_ec2_list.ui).to receive(:list).with(output_column,:uneven_columns_across, output_column_count)
127
- knife_ec2_list.run
128
- end
129
- end
130
- end
131
- end
1
+ # License:: Apache License, Version 2.0
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+
16
+ require File.expand_path('../../spec_helper', __FILE__)
17
+ require 'fog/aws'
18
+
19
+ describe Chef::Knife::Ec2ServerList do
20
+
21
+ describe '#run' do
22
+ let(:knife_ec2_list) { Chef::Knife::Ec2ServerList.new }
23
+ let(:ec2_connection) { double(Fog::Compute::AWS) }
24
+ before do
25
+ allow(knife_ec2_list).to receive(:connection).and_return(ec2_connection)
26
+ end
27
+
28
+ it 'invokes validate!' do
29
+ ec2_servers = double()
30
+ allow(ec2_connection).to receive(:servers).and_return(ec2_servers)
31
+ allow(knife_ec2_list.ui).to receive(:warn)
32
+ expect(knife_ec2_list).to receive(:validate!)
33
+ knife_ec2_list.run
34
+ end
35
+
36
+ context 'when region is not specified' do
37
+ it 'shows warning that default region will be will be used' do
38
+ knife_ec2_list.config.delete(:region)
39
+ Chef::Config[:knife].delete(:region)
40
+ ec2_servers = double()
41
+ allow(ec2_connection).to receive(:servers).and_return(ec2_servers)
42
+ allow(knife_ec2_list).to receive(:validate!)
43
+ expect(knife_ec2_list.ui).to receive(:warn).with("No region was specified in knife.rb or as an argument. The default region, us-east-1, will be used:")
44
+ knife_ec2_list.run
45
+ end
46
+ end
47
+
48
+ context '--format option' do
49
+ context 'when format=summary' do
50
+ before do
51
+ knife_ec2_list.config[:format] = 'summary'
52
+ allow(knife_ec2_list.ui).to receive(:warn)
53
+ end
54
+
55
+ it 'shows the output without Tags and Availability Zone in summary format' do
56
+ output_column = ["Instance ID", "Public IP", "Private IP", "Flavor",
57
+ "Image", "SSH Key", "Security Groups", "IAM Profile", "State"]
58
+ output_column_count = output_column.length
59
+ allow(ec2_connection).to receive(:servers).and_return([])
60
+ allow(knife_ec2_list).to receive(:validate!)
61
+ expect(knife_ec2_list.ui).to receive(:list).with(output_column,:uneven_columns_across, output_column_count)
62
+ knife_ec2_list.run
63
+ end
64
+ end
65
+
66
+ context 'when format=json' do
67
+ before do
68
+ knife_ec2_list.config[:format] = 'json'
69
+ allow(knife_ec2_list.ui).to receive(:warn)
70
+ end
71
+
72
+ it 'shows the output without Tags and Availability Zone in summary format' do
73
+ allow(ec2_connection).to receive(:servers).and_return([])
74
+ allow(knife_ec2_list).to receive(:validate!)
75
+ allow(knife_ec2_list).to receive(:format_for_display)
76
+ expect(knife_ec2_list).to receive(:output)
77
+ knife_ec2_list.run
78
+ end
79
+ end
80
+ end
81
+
82
+ context 'when --tags option is passed' do
83
+ before do
84
+ knife_ec2_list.config[:format] = 'summary'
85
+ allow(knife_ec2_list.ui).to receive(:warn)
86
+ allow(ec2_connection).to receive(:servers).and_return([])
87
+ allow(knife_ec2_list).to receive(:validate!)
88
+ end
89
+
90
+ context 'when single tag is passed' do
91
+ it 'shows single tag field in the output' do
92
+ knife_ec2_list.config[:tags] = 'tag1'
93
+ output_column = ["Instance ID", "Public IP", "Private IP", "Flavor",
94
+ "Image", "SSH Key", "Security Groups", "Tag:tag1", "IAM Profile", "State"]
95
+ output_column_count = output_column.length
96
+ expect(knife_ec2_list.ui).to receive(:list).with(output_column,:uneven_columns_across, output_column_count)
97
+ knife_ec2_list.run
98
+ end
99
+ end
100
+
101
+ context 'when multiple tags are passed' do
102
+ it 'shows multiple tags fields in the output' do
103
+ knife_ec2_list.config[:tags] = 'tag1,tag2'
104
+ output_column = ["Instance ID", "Public IP", "Private IP", "Flavor",
105
+ "Image", "SSH Key", "Security Groups", "Tag:tag1", "Tag:tag2", "IAM Profile", "State"]
106
+ output_column_count = output_column.length
107
+ expect(knife_ec2_list.ui).to receive(:list).with(output_column,:uneven_columns_across, output_column_count)
108
+ knife_ec2_list.run
109
+ end
110
+ end
111
+ end
112
+
113
+ context 'when --availability-zone is passed' do
114
+ before do
115
+ knife_ec2_list.config[:format] = 'summary'
116
+ allow(knife_ec2_list.ui).to receive(:warn)
117
+ allow(ec2_connection).to receive(:servers).and_return([])
118
+ allow(knife_ec2_list).to receive(:validate!)
119
+ end
120
+
121
+ it 'shows the availability zones in the output' do
122
+ knife_ec2_list.config[:az] = true
123
+ output_column = ["Instance ID", "Public IP", "Private IP", "Flavor", "AZ",
124
+ "Image", "SSH Key", "Security Groups", "IAM Profile", "State"]
125
+ output_column_count = output_column.length
126
+ expect(knife_ec2_list.ui).to receive(:list).with(output_column,:uneven_columns_across, output_column_count)
127
+ knife_ec2_list.run
128
+ end
129
+ end
130
+ end
131
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-08 00:00:00.000000000 Z
12
+ date: 2016-12-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog-aws
@@ -93,14 +93,14 @@ dependencies:
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '10.1'
96
+ version: '11.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: '10.1'
103
+ version: '11.0'
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: sdoc
106
106
  requirement: !ruby/object:Gem::Requirement
@@ -143,6 +143,7 @@ files:
143
143
  - lib/chef/knife/s3_source.rb
144
144
  - lib/knife-ec2/version.rb
145
145
  - spec/spec_helper.rb
146
+ - spec/unit/ec2_flavor_list_spec.rb
146
147
  - spec/unit/ec2_server_create_spec.rb
147
148
  - spec/unit/ec2_server_delete_spec.rb
148
149
  - spec/unit/ec2_server_list_spec.rb
@@ -160,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
161
  requirements:
161
162
  - - ">="
162
163
  - !ruby/object:Gem::Version
163
- version: '0'
164
+ version: 2.2.2
164
165
  required_rubygems_version: !ruby/object:Gem::Requirement
165
166
  requirements:
166
167
  - - ">="
@@ -168,9 +169,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
169
  version: '0'
169
170
  requirements: []
170
171
  rubyforge_project:
171
- rubygems_version: 2.5.1
172
+ rubygems_version: 2.6.7
172
173
  signing_key:
173
174
  specification_version: 4
174
175
  summary: EC2 Support for Chef's Knife Command
175
176
  test_files: []
176
- has_rdoc: