spec/lib/ec2ssh/cli_spec.rb in ec2ssh-2.0.3 vs spec/lib/ec2ssh/cli_spec.rb in ec2ssh-2.0.4
- old
+ new
@@ -6,12 +6,12 @@
before(:all) do
Ec2ssh::Hosts.tap do |cls|
cls.class_eval do
def all
[
- {:host => 'db-01', :dns_name => 'ec2-1-1-1-1.ap-northeast-1.ec2.amazonaws.com'},
- {:host => 'db-02', :dns_name => 'ec2-1-1-1-2.ap-northeast-1.ec2.amazonaws.com'},
+ {:host => 'db-01.ap-northeast-1', :dns_name => 'ec2-1-1-1-1.ap-northeast-1.ec2.amazonaws.com'},
+ {:host => 'db-02.ap-northeast-1', :dns_name => 'ec2-1-1-1-2.ap-northeast-1.ec2.amazonaws.com'},
]
end
end
end
end
@@ -71,15 +71,17 @@
HostName 1.2.3.4
### EC2SSH BEGIN ###
# Generated by ec2ssh http://github.com/mirakui/ec2ssh
# DO NOT edit this block!
# Updated 2013-01-01T00:00:00+00:00
-Host db-01
+# section: default
+Host db-01.ap-northeast-1
HostName ec2-1-1-1-1.ap-northeast-1.ec2.amazonaws.com
-Host db-02
+Host db-02.ap-northeast-1
HostName ec2-1-1-1-2.ap-northeast-1.ec2.amazonaws.com
+
### EC2SSH END ###
END
end
describe '#update with aws-keys option' do
@@ -100,19 +102,56 @@
subject { @output }
context do
let(:keyname) { 'default' }
it { should =~ /Updated 2 hosts/ }
+ it { should =~ /# section: default/ }
end
context do
let(:keyname) { 'key1' }
it { should =~ /Updated 2 hosts/ }
+ it { should =~ /# section: key1/ }
end
context do
let(:keyname) { 'key2' }
it { should_not =~ /^Updated 2 hosts/ }
+ end
+ end
+
+ describe '#update with aws-keys option in multiple times' do
+ before do
+ silence(:stdout) do
+ cli.start %W[init --path #{ssh_config_path} --dotfile #{dotfile_path}]
+ end
+ dotfile = Ec2ssh::Dotfile.load(dotfile_path)
+ dotfile['aws_keys']['key1'] = {
+ 'access_key_id' => 'ACCESS_KEY_ID',
+ 'secret_access_key' => 'SECRET_ACCESS_KEY'
+ }
+ dotfile['aws_keys']['key2'] = {
+ 'access_key_id' => 'ACCESS_KEY_ID',
+ 'secret_access_key' => 'SECRET_ACCESS_KEY'
+ }
+ @output = capture(:stdout) do
+ cli.start %W[update --path #{ssh_config_path} --dotfile #{dotfile_path} --aws-key key1]
+ cli.start %W[update --path #{ssh_config_path} --dotfile #{dotfile_path} --aws-key #{keyname}]
+ end
+ end
+
+ subject { @output }
+
+ context 'when updated by the same key' do
+ let(:keyname) { 'key1' }
+ it { subject.should =~ /# section: key1/ }
+ it { subject.should_not =~ /# section: key2/ }
+ end
+
+ context 'when updated by different key' do
+ let(:keyname) { 'key2' }
+ it { subject.should =~ /# section: key1/ }
+ it { subject.should =~ /# section: key2/ }
end
end
describe '#remove' do
before do