File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,14 @@ def print(*items)
131
131
nil
132
132
end
133
133
134
+ def size
135
+ stat . size
136
+ end
137
+
138
+ def rewind
139
+ self . pos = 0
140
+ end
141
+
134
142
# Writes each argument to the stream, appending a newline to any item
135
143
# that does not already end in a newline. Array arguments are flattened.
136
144
def puts ( *items )
Original file line number Diff line number Diff line change @@ -156,4 +156,20 @@ def test_stat_should_return_attributes_object_for_handle
156
156
@sftp . expects ( :fstat! ) . with ( "handle" ) . returns ( stat )
157
157
assert_equal stat , @file . stat
158
158
end
159
- end
159
+
160
+ def test_size_should_return_size_from_stat
161
+ stat = stub ( size : 1024 )
162
+ @sftp . expects ( :fstat! ) . with ( "handle" ) . returns ( stat )
163
+ assert_equal 1024 , @file . size
164
+ end
165
+
166
+ def test_rewind
167
+ @sftp . expects ( :write! ) . with ( "handle" , 0 , "hello world\n " )
168
+ @sftp . expects ( :read! ) . with ( "handle" , 12 , 8192 ) . returns ( "hello world\n " )
169
+ @sftp . expects ( :read! ) . with ( "handle" , 0 , 8192 ) . returns ( "hello world\n " )
170
+ @file . puts "hello world\n "
171
+ assert_equal "hello" , @file . read ( 5 )
172
+ @file . rewind
173
+ assert_equal "hello world" , @file . read ( 11 )
174
+ end
175
+ end
You can’t perform that action at this time.
0 commit comments