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

Missing Net::SFTP::Operations::File#<< #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions lib/net/sftp/operations/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ def write(data)
data.bytes.length
end

alias << write

# Writes each argument to the stream. If +$\+ is set, it will be written
# after all arguments have been written.
def print(*items)
Expand Down
6 changes: 6 additions & 0 deletions test/test_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ def test_write_should_write_data_and_increment_pos_and_return_data_length
assert_equal 11, @file.pos
end

def test_double_less_should_write_data_and_increment_pos_and_return_data_length
@sftp.expects(:write!).with("handle", 0, "hello world")
assert_equal 11, @file << ("hello world")
assert_equal 11, @file.pos
end

def test_write_after_pos_assignment_should_write_at_position
@sftp.expects(:write!).with("handle", 15, "hello world")
@file.pos = 15
Expand Down