knife-ec2 0.11.0.rc.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,7 +25,7 @@ describe Chef::Knife::Ec2ServerDelete do
25
25
  before(:each) do
26
26
  {
27
27
  :image => 'image',
28
- :aws_ssh_key_id => 'aws_ssh_key_id',
28
+ :ssh_key_name => 'ssh_key_name',
29
29
  :aws_access_key_id => 'aws_access_key_id',
30
30
  :aws_secret_access_key => 'aws_secret_access_key'
31
31
  }.each do |key, value|
@@ -40,98 +40,100 @@ describe Chef::Knife::Ec2ServerDelete do
40
40
  :groups => ['group1', 'group2'],
41
41
  :security_group_ids => ['sg-00aa11bb'],
42
42
  :dns_name => 'ec2-75.101.253.10.compute-1.amazonaws.com',
43
- :iam_instance_profile => {},
43
+ :iam_instance_profile => {},
44
44
  :public_ip_address => '75.101.253.10',
45
45
  :private_dns_name => 'ip-10-251-75-20.ec2.internal',
46
46
  :private_ip_address => '10.251.75.20',
47
- :root_device_type => 'not_ebs' }
47
+ :root_device_type => 'not_ebs',
48
+ :tags => {'Name' => 'foo'}
49
+ }
48
50
  @knife_ec2_delete = Chef::Knife::Ec2ServerDelete.new
49
51
  @ec2_servers = double()
50
- @knife_ec2_delete.ui.stub(:confirm)
51
- @knife_ec2_delete.stub(:msg_pair)
52
+ allow(@knife_ec2_delete.ui).to receive(:confirm)
53
+ allow(@knife_ec2_delete).to receive(:msg_pair)
52
54
  @ec2_server = double(@ec2_server_attribs)
53
55
  @ec2_connection = double(Fog::Compute::AWS)
54
- @ec2_connection.stub(:servers).and_return(@ec2_servers)
55
- @knife_ec2_delete.ui.stub(:warn)
56
+ allow(@ec2_connection).to receive(:servers).and_return(@ec2_servers)
57
+ allow(@knife_ec2_delete.ui).to receive(:warn)
56
58
  end
57
59
 
58
60
  it "should invoke validate!" do
59
61
  knife_ec2_delete = Chef::Knife::Ec2ServerDelete.new
60
- knife_ec2_delete.should_receive(:validate!)
62
+ expect(knife_ec2_delete).to receive(:validate!)
61
63
  knife_ec2_delete.run
62
64
  end
63
65
 
64
66
  it "should use invoke fog api to delete instance if instance id is passed" do
65
- @ec2_servers.should_receive(:get).with('foo').and_return(@ec2_server)
66
- Fog::Compute::AWS.should_receive(:new).and_return(@ec2_connection)
67
+ expect(@ec2_servers).to receive(:get).with('foo').and_return(@ec2_server)
68
+ expect(Fog::Compute::AWS).to receive(:new).and_return(@ec2_connection)
67
69
  @knife_ec2_delete.name_args = ['foo']
68
- @knife_ec2_delete.should_receive(:validate!)
69
- @ec2_server.should_receive(:destroy)
70
+ expect(@knife_ec2_delete).to receive(:validate!)
71
+ expect(@ec2_server).to receive(:destroy)
70
72
  @knife_ec2_delete.run
71
73
  end
72
74
 
73
75
  it "should use node_name to figure out instance id if not specified explicitly" do
74
- @ec2_servers.should_receive(:get).with('foo').and_return(@ec2_server)
75
- Fog::Compute::AWS.should_receive(:new).and_return(@ec2_connection)
76
- @knife_ec2_delete.should_receive(:validate!)
77
- @ec2_server.should_receive(:destroy)
76
+ expect(@ec2_servers).to receive(:get).with('foo').and_return(@ec2_server)
77
+ expect(Fog::Compute::AWS).to receive(:new).and_return(@ec2_connection)
78
+ expect(@knife_ec2_delete).to receive(:validate!)
79
+ expect(@ec2_server).to receive(:destroy)
78
80
  @knife_ec2_delete.config[:purge] = false
79
81
  @knife_ec2_delete.config[:chef_node_name] = 'baz'
80
82
  double_node = double(Chef::Node)
81
- double_node.should_receive(:attribute?).with('ec2').and_return(true)
82
- double_node.should_receive(:[]).with('ec2').and_return('instance_id'=>'foo')
83
+ expect(double_node).to receive(:attribute?).with('ec2').and_return(true)
84
+ expect(double_node).to receive(:[]).with('ec2').and_return('instance_id'=>'foo')
83
85
  double_search = double(Chef::Search::Query)
84
- double_search.should_receive(:search).with(:node,"name:baz").and_return([[double_node],nil,nil])
85
- Chef::Search::Query.should_receive(:new).and_return(double_search)
86
+ expect(double_search).to receive(:search).with(:node,"name:baz").and_return([[double_node],nil,nil])
87
+ expect(Chef::Search::Query).to receive(:new).and_return(double_search)
86
88
  @knife_ec2_delete.name_args = []
87
89
  @knife_ec2_delete.run
88
90
  end
89
91
 
90
92
  describe "when --purge is passed" do
91
93
  it "should use the node name if its set" do
92
- @ec2_servers.should_receive(:get).with('foo').and_return(@ec2_server)
93
- Fog::Compute::AWS.should_receive(:new).and_return(@ec2_connection)
94
+ expect(@ec2_servers).to receive(:get).with('foo').and_return(@ec2_server)
95
+ expect(Fog::Compute::AWS).to receive(:new).and_return(@ec2_connection)
94
96
  @knife_ec2_delete.name_args = ['foo']
95
- @knife_ec2_delete.should_receive(:validate!)
96
- @ec2_server.should_receive(:destroy)
97
+ expect(@knife_ec2_delete).to receive(:validate!)
98
+ expect(@ec2_server).to receive(:destroy)
97
99
  @knife_ec2_delete.config[:purge] = true
98
100
  @knife_ec2_delete.config[:chef_node_name] = 'baz'
99
- Chef::Node.should_receive(:load).with('baz').and_return(double(:destroy=>true))
100
- Chef::ApiClient.should_receive(:load).with('baz').and_return(double(:destroy=>true))
101
+ expect(Chef::Node).to receive(:load).with('baz').and_return(double(:destroy=>true))
102
+ expect(Chef::ApiClient).to receive(:load).with('baz').and_return(double(:destroy=>true))
101
103
  @knife_ec2_delete.run
102
104
  end
103
105
 
104
106
  it "should search for the node name using the instance id when node name is not specified" do
105
- @ec2_servers.should_receive(:get).with('i-foo').and_return(@ec2_server)
106
- Fog::Compute::AWS.should_receive(:new).and_return(@ec2_connection)
107
+ expect(@ec2_servers).to receive(:get).with('i-foo').and_return(@ec2_server)
108
+ expect(Fog::Compute::AWS).to receive(:new).and_return(@ec2_connection)
107
109
  @knife_ec2_delete.name_args = ['i-foo']
108
- @knife_ec2_delete.should_receive(:validate!)
109
- @ec2_server.should_receive(:destroy)
110
+ expect(@knife_ec2_delete).to receive(:validate!)
111
+ expect(@ec2_server).to receive(:destroy)
110
112
  @knife_ec2_delete.config[:purge] = true
111
113
  @knife_ec2_delete.config[:chef_node_name] = nil
112
114
  double_search = double(Chef::Search::Query)
113
115
  double_node = double(Chef::Node)
114
- double_node.should_receive(:name).and_return("baz")
115
- Chef::Node.should_receive(:load).with('baz').and_return(double(:destroy=>true))
116
- Chef::ApiClient.should_receive(:load).with('baz').and_return(double(:destroy=>true))
117
- double_search.should_receive(:search).with(:node,"ec2_instance_id:i-foo").and_return([[double_node],nil,nil])
118
- Chef::Search::Query.should_receive(:new).and_return(double_search)
116
+ expect(double_node).to receive(:name).and_return("baz")
117
+ expect(Chef::Node).to receive(:load).with('baz').and_return(double(:destroy=>true))
118
+ expect(Chef::ApiClient).to receive(:load).with('baz').and_return(double(:destroy=>true))
119
+ expect(double_search).to receive(:search).with(:node,"ec2_instance_id:i-foo").and_return([[double_node],nil,nil])
120
+ expect(Chef::Search::Query).to receive(:new).and_return(double_search)
119
121
  @knife_ec2_delete.run
120
122
  end
121
123
 
122
124
  it "should use the instance id if search does not return anything" do
123
- @ec2_servers.should_receive(:get).with('i-foo').and_return(@ec2_server)
124
- Fog::Compute::AWS.should_receive(:new).and_return(@ec2_connection)
125
+ expect(@ec2_servers).to receive(:get).with('i-foo').and_return(@ec2_server)
126
+ expect(Fog::Compute::AWS).to receive(:new).and_return(@ec2_connection)
125
127
  @knife_ec2_delete.name_args = ['i-foo']
126
- @knife_ec2_delete.should_receive(:validate!)
127
- @ec2_server.should_receive(:destroy)
128
+ expect(@knife_ec2_delete).to receive(:validate!)
129
+ expect(@ec2_server).to receive(:destroy)
128
130
  @knife_ec2_delete.config[:purge] = true
129
131
  @knife_ec2_delete.config[:chef_node_name] = nil
130
- Chef::Node.should_receive(:load).with('i-foo').and_return(double(:destroy=>true))
131
- Chef::ApiClient.should_receive(:load).with('i-foo').and_return(double(:destroy=>true))
132
+ expect(Chef::Node).to receive(:load).with('i-foo').and_return(double(:destroy=>true))
133
+ expect(Chef::ApiClient).to receive(:load).with('i-foo').and_return(double(:destroy=>true))
132
134
  double_search = double(Chef::Search::Query)
133
- double_search.should_receive(:search).with(:node,"ec2_instance_id:i-foo").and_return([[],nil,nil])
134
- Chef::Search::Query.should_receive(:new).and_return(double_search)
135
+ expect(double_search).to receive(:search).with(:node,"ec2_instance_id:i-foo").and_return([[],nil,nil])
136
+ expect(Chef::Search::Query).to receive(:new).and_return(double_search)
135
137
  @knife_ec2_delete.run
136
138
  end
137
139
  end
@@ -3,8 +3,8 @@ require 'fog'
3
3
 
4
4
  describe Chef::Knife::S3Source do
5
5
  before(:each) do
6
- @bucket_name = 'my.bucket'
7
- @test_file_path = 'path/to/file.pem'
6
+ @bucket_name = 'mybucket'
7
+ @test_file_path = 'path/file.pem'
8
8
  @test_file_content = "TEST CONTENT\n"
9
9
 
10
10
  Fog.mock!
@@ -27,27 +27,49 @@ describe Chef::Knife::S3Source do
27
27
 
28
28
  @s3_connection = double(Fog::Storage::AWS)
29
29
  @s3_source = Chef::Knife::S3Source.new
30
-
31
- @s3_source.url = "s3://#{@bucket_name}/#{@test_file_path}"
32
30
  end
33
31
 
34
- it 'converts URI to path with leading / removed' do
35
- @s3_source.instance_eval { path }
36
- @s3_source.instance_eval { path }.should eq(@test_file_path)
37
- end
32
+ context "for http URL format" do
33
+ it 'converts URI to path with leading / removed' do
34
+ @s3_source.url = "http://s3.amazonaws.com/#{@bucket_name}/#{@test_file_path}"
35
+ @s3_source.instance_eval { path }
36
+ expect(@s3_source.instance_eval { path }).to eq(@test_file_path)
37
+ end
38
38
 
39
- it 'correctly retrieves the bucket name from the URI' do
40
- @s3_source.instance_eval { bucket }
41
- @s3_source.instance_eval { bucket }.should eq(@bucket_name)
42
- end
39
+ it 'correctly retrieves the bucket name from the URI' do
40
+ @s3_source.url = "http://s3.amazonaws.com/#{@bucket_name}/#{@test_file_path}"
41
+ @s3_source.instance_eval { bucket }
42
+ expect(@s3_source.instance_eval { bucket }).to eq(@bucket_name)
43
+ end
44
+
45
+ it 'gets back the correct bucket contents' do
46
+ @s3_source.url = "http://s3.amazonaws.com/#{@bucket_name}/#{@test_file_path}"
47
+ expect(@s3_source.body).to eq(@test_file_content)
48
+ end
43
49
 
44
- it 'gets back the correct bucket contents' do
45
- @s3_source.body.should eq(@test_file_content)
50
+ it 'gets back a bucket object with bucket_obj' do
51
+ @s3_source.url = "http://s3.amazonaws.com/#{@bucket_name}/#{@test_file_path}"
52
+ @s3_source.instance_eval { bucket_obj }
53
+ expect(@s3_source.instance_eval { bucket_obj }).to be_kind_of(Fog::Storage::AWS::Directory)
54
+ end
46
55
  end
47
56
 
48
- it 'gets back a bucket object with bucket_obj' do
49
- @s3_source.instance_eval { bucket_obj }
50
- @s3_source.instance_eval { bucket_obj }.should
51
- be_kind_of(Fog::Storage::AWS::Directory)
57
+ context "for s3 URL format" do
58
+ it 'correctly retrieves the bucket name from the URI' do
59
+ @s3_source.url = "s3://#{@bucket_name}/#{@test_file_path}"
60
+ @s3_source.instance_eval { bucket }
61
+ expect(@s3_source.instance_eval { bucket }).to eq(@bucket_name)
62
+ end
63
+
64
+ it 'gets back the correct bucket contents' do
65
+ @s3_source.url = "s3://#{@bucket_name}/#{@test_file_path}"
66
+ expect(@s3_source.body).to eq(@test_file_content)
67
+ end
68
+
69
+ it 'gets back a bucket object with bucket_obj' do
70
+ @s3_source.url = "s3://#{@bucket_name}/#{@test_file_path}"
71
+ @s3_source.instance_eval { bucket_obj }
72
+ expect(@s3_source.instance_eval { bucket_obj }).to be_kind_of(Fog::Storage::AWS::Directory)
73
+ end
52
74
  end
53
75
  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.11.0.rc.0
4
+ version: 0.11.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: 2015-06-09 00:00:00.000000000 Z
12
+ date: 2015-08-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 1.25.0
20
+ version: 1.29.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 1.25.0
27
+ version: 1.29.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: knife-windows
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -40,53 +40,39 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  version: 0.8.2
42
42
  - !ruby/object:Gem::Dependency
43
- name: mixlib-config
43
+ name: chef
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '2.0'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: '2.0'
56
- - !ruby/object:Gem::Dependency
57
- name: chef
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
48
+ version: '12.0'
60
49
  - - ">="
61
50
  - !ruby/object:Gem::Version
62
- version: 11.16.2
63
- - - "<"
64
- - !ruby/object:Gem::Version
65
- version: '12'
51
+ version: 12.2.1
66
52
  type: :development
67
53
  prerelease: false
68
54
  version_requirements: !ruby/object:Gem::Requirement
69
55
  requirements:
70
- - - ">="
56
+ - - "~>"
71
57
  - !ruby/object:Gem::Version
72
- version: 11.16.2
73
- - - "<"
58
+ version: '12.0'
59
+ - - ">="
74
60
  - !ruby/object:Gem::Version
75
- version: '12'
61
+ version: 12.2.1
76
62
  - !ruby/object:Gem::Dependency
77
63
  name: rspec
78
64
  requirement: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: '2.14'
68
+ version: '3.0'
83
69
  type: :development
84
70
  prerelease: false
85
71
  version_requirements: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '2.14'
75
+ version: '3.0'
90
76
  - !ruby/object:Gem::Dependency
91
77
  name: rake
92
78
  requirement: !ruby/object:Gem::Requirement
@@ -162,9 +148,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
148
  version: '0'
163
149
  required_rubygems_version: !ruby/object:Gem::Requirement
164
150
  requirements:
165
- - - ">"
151
+ - - ">="
166
152
  - !ruby/object:Gem::Version
167
- version: 1.3.1
153
+ version: '0'
168
154
  requirements: []
169
155
  rubyforge_project:
170
156
  rubygems_version: 2.4.4
@@ -177,3 +163,4 @@ test_files:
177
163
  - spec/unit/ec2_server_delete_spec.rb
178
164
  - spec/unit/s3_source_deps_spec.rb
179
165
  - spec/unit/s3_source_spec.rb
166
+ has_rdoc: