@@ -142,6 +142,16 @@ def test_rewind_should_reset_to_beginning_of_file
142
142
assert_equal 0 , @file . pos
143
143
end
144
144
145
+ def test_rewind
146
+ @sftp . expects ( :write! ) . with ( "handle" , 0 , "hello world\n " )
147
+ @sftp . expects ( :read! ) . with ( "handle" , 12 , 8192 ) . returns ( "hello world\n " )
148
+ @sftp . expects ( :read! ) . with ( "handle" , 0 , 8192 ) . returns ( "hello world\n " )
149
+ @file . puts "hello world\n "
150
+ assert_equal "hello" , @file . read ( 5 )
151
+ @file . rewind
152
+ assert_equal "hello world" , @file . read ( 11 )
153
+ end
154
+
145
155
def test_write_should_write_data_and_increment_pos_and_return_data_length
146
156
@sftp . expects ( :write! ) . with ( "handle" , 0 , "hello world" )
147
157
assert_equal 11 , @file . write ( "hello world" )
@@ -202,14 +212,4 @@ def test_size_should_return_size_from_stat
202
212
@sftp . expects ( :fstat! ) . with ( "handle" ) . returns ( stat )
203
213
assert_equal 1024 , @file . size
204
214
end
205
-
206
- def test_rewind
207
- @sftp . expects ( :write! ) . with ( "handle" , 0 , "hello world\n " )
208
- @sftp . expects ( :read! ) . with ( "handle" , 12 , 8192 ) . returns ( "hello world\n " )
209
- @sftp . expects ( :read! ) . with ( "handle" , 0 , 8192 ) . returns ( "hello world\n " )
210
- @file . puts "hello world\n "
211
- assert_equal "hello" , @file . read ( 5 )
212
- @file . rewind
213
- assert_equal "hello world" , @file . read ( 11 )
214
- end
215
215
end
0 commit comments