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
4141 end
4242
4343 # 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 )
4545 if @body
4646 ::File . open ( path , mode , **options ) do |file |
4747 self . each do |chunk |
Original file line number Diff line number Diff line change @@ -40,7 +40,13 @@ def initialize(body)
4040 reader . save ( path )
4141 expect ( File . read ( path ) ) . to be == 'thequickbrownfox'
4242 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+
4450 it 'mirrors the interface of File.open' do
4551 reader . save ( path , 'w' )
4652 expect ( File . read ( path ) ) . to be == 'thequickbrownfox'
You can’t perform that action at this time.
0 commit comments