Permalink
Browse files

Merge branch 'feature/user@sever' into develop

  • Loading branch information...
catsby committed Jan 28, 2011
2 parents 22fb069 + 36a0622 commit 856e0a2ae2a3459ac7a15ca0d6b44369b9025075
Showing with 26 additions and 5 deletions.
  1. +10 −2 features/gt_scp_file.feature
  2. +6 −2 features/step_definitions/gt_scp_steps.rb
  3. +10 −1 lib/growl-transfer/gt_scp.rb
@@ -7,8 +7,16 @@ Feature: growl-down downloads a file via scp
And not have to watch or check the progress

Scenario: Download file assuming ssh keyless authentication
Given I have an available server "ctshryock.com"
And "growl-down-test/unicorns.zip" as the file name
Given I have ssh keyless auth setup on "ctshryock.com"
And specify "growl-down-test/unicorns.zip" as the file name
When I run "download"
Then I should see "Finished!"
And TEST_DIR should contains "unicorns.zip" file

Scenario: Download file assuming ssh keyless auth, but specify a username
Given I have ssh keyless auth setup on "ctshryock.com"
And I specify "clint" as the username before the url
And specify "growl-down-test/unicorns.zip" as the file name
When I run "download"
Then I should see "Finished!"
And TEST_DIR should contains "unicorns.zip" file
@@ -25,15 +25,19 @@ def output
@output ||= Output.new
end

Given /^I have an available server "([^"]*)"$/ do |remote_host|
Given /^I have ssh keyless auth setup on "([^"]*)"$/ do |remote_host|
@remote = []
@remote << remote_host
end

When /^"([^"]*)" as the file name$/ do |remote_path|
Given /^specify "([^"]*)" as the file name$/ do |remote_path|
@remote << remote_path
end

Given /^I specify "([^"]*)" as the username before the url$/ do |arg1|
@remote[0] = 'clint' + '@' + @remote[0]
end

When /^I run "([^"]*)"$/ do |arg1|
gd_scp = GrowlTransfer::GTScp.new(output)
gd_scp.download(@remote.join(':'), TEST_DIR)
@@ -8,7 +8,16 @@ def download(remote, local_path)
@output.puts "Downloading #{remote}"
params = remote.split(":")
file = params.last.split("/").last
Net::SCP.start(params[0], ENV['USER']) do |scp|

if params[0].include? '@'
server = params[0].split('@').last
user = params[0].split('@').first
else
server = params[0]
user = ENV['USER']
end

Net::SCP.start(server, user) do |scp|
scp.download!(params[1], local_path, {:recursive => true, :verbose => true}) do |ch, name, sent, total|
# => progress?
end

0 comments on commit 856e0a2

Please sign in to comment.