File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ def finish
41
41
end
42
42
43
43
# Write the body of the response to the given file path.
44
- def save ( path , mode = ::File ::WRONLY |::File ::CREAT , **options )
44
+ def save ( path , mode = ::File ::WRONLY |::File ::CREAT |:: File :: TRUNC , **options )
45
45
if @body
46
46
::File . open ( path , mode , **options ) do |file |
47
47
self . each do |chunk |
Original file line number Diff line number Diff line change @@ -40,7 +40,13 @@ def initialize(body)
40
40
reader . save ( path )
41
41
expect ( File . read ( path ) ) . to be == 'thequickbrownfox'
42
42
end
43
-
43
+
44
+ it 'saves by truncating an existing file if it exists' do
45
+ File . write ( path , 'hello' * 100 )
46
+ reader . save ( path )
47
+ expect ( File . read ( path ) ) . to be == 'thequickbrownfox'
48
+ end
49
+
44
50
it 'mirrors the interface of File.open' do
45
51
reader . save ( path , 'w' )
46
52
expect ( File . read ( path ) ) . to be == 'thequickbrownfox'
You can’t perform that action at this time.
0 commit comments