Skip to content

Commit

Permalink
missing tests and style changes for last pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
wbailey committed Jun 1, 2012
1 parent eb2ccbe commit 17a0a96
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/claws/command/ec2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,13 @@ def self.exec(options)
puts 'connecting to server...'

identity = config.ssh.identity.nil? ? '' : "-i #{config.ssh.identity}"
current_instance = instances[selection.to_i]
ssh_opts = {:identity => identity, :ssh_user => config.ssh.user}

if instances[selection.to_i].vpc?
ssh(ssh_opts.merge(:host => current_instance.private_ip_address))
else
ssh(ssh_opts.merge(:host => current_instance.dns_name))
end
end
end
instance = instances[selection.to_i]

hostname = instance.vpc? ? instance.private_ip_address : instance.dns_name

def self.ssh(opts={})
system "ssh #{opts[:identity]} #{opts[:ssh_user]}@#{opts[:host]}"
system "ssh #{identity} #{config.ssh.user}@#{hostname}"
end
end
end
end
Expand Down
18 changes: 18 additions & 0 deletions spec/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
'capistrano' => {
'home' => 'test',
},
'ssh' => {
'user' => 'test',
'identity' => 'test/id_rsa',
},
'aws' => {
'access_key_id' => 'asdf',
'secret_access_key' => 'qwer',
Expand Down Expand Up @@ -61,6 +65,20 @@
end
end

context 'SSH' do
before :each do
YAML.should_receive(:load_file).and_return(yaml)
end

it 'defines user' do
config.ssh.user.should == 'test'
end

it 'defines the identity file' do
config.ssh.identity.should == 'test/id_rsa'
end
end

context 'AWS' do
before :each do
YAML.should_receive(:load_file).and_return(yaml)
Expand Down

0 comments on commit 17a0a96

Please sign in to comment.