Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No longer strip whitespace/newlines in capture method on Netssh backend #239

Merged
merged 1 commit into from
Apr 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ appear at the top.

* Add your entries below here, remember to credit yourself however you want
to be credited!
* No longer strip whitespace or newlines in `capture` method on Netssh backend. @robd
* This is to make the `Local` and `Netssh` backends consistent (they diverged at 7d15a9a)
* If you need the old behaviour back, call `.strip` (or `.chomp`) on the captured string i.e. `capture(:my_command).strip`
* Simplified backend hierarchy. @robd
* Moved duplicate implementations of `make`, `rake`, `test`, `capture`, `background` on to `Abstract` backend.
* Backend implementations now only need to implement `execute_command`, `upload!` and `download!`
Expand Down
6 changes: 0 additions & 6 deletions lib/sshkit/backends/netssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ def ssh_options
end
end

def capture(*args)
# The behaviour to strip the full stdout was removed from the local backend in commit 7d15a9a,
# but was left in for the net ssh backend.
super(*args).strip
end

def upload!(local, remote, options = {})
summarizer = transfer_summarizer('Uploading')
with_ssh do |ssh|
Expand Down
13 changes: 6 additions & 7 deletions test/functional/backends/test_netssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ def test_capture
captured_command_result = capture(:uname)
end.run

assert captured_command_result
assert_match captured_command_result, /Linux|Darwin/
assert_includes %W(Linux\n Darwin\n), captured_command_result
end
end
end
Expand Down Expand Up @@ -87,17 +86,17 @@ def test_test_does_not_raise_on_non_zero_exit_status
end.run
end

def test_upload_file
file_contents = ""
def test_upload_and_then_capture_file_contents
actual_file_contents = ""
file_name = File.join("/tmp", SecureRandom.uuid)
File.open file_name, 'w+' do |f|
f.write 'example_file'
f.write "Some Content\nWith a newline and trailing spaces \n "
end
Netssh.new(a_host) do
upload!(file_name, file_name)
file_contents = capture(:cat, file_name)
actual_file_contents = capture(:cat, file_name)
end.run
assert_equal "example_file", file_contents
assert_equal "Some Content\nWith a newline and trailing spaces \n ", actual_file_contents
end

def test_upload_string_io
Expand Down