File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed
Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change 55/doc /
66/pkg /
77/spec /reports /
8+ /spec /protocol /http /body /reader_spec.txt
89/tmp /
910/external /
1011
Original file line number Diff line number Diff line change @@ -57,9 +57,9 @@ def finish
5757 end
5858
5959 # Write the body of the response to the given file path.
60- def save ( path , mode = ::File ::WRONLY |::File ::CREAT , *args )
60+ def save ( path , mode = ::File ::WRONLY |::File ::CREAT , ** options )
6161 if @body
62- ::File . open ( path , mode , *args ) do |file |
62+ ::File . open ( path , mode , ** options ) do |file |
6363 self . each do |chunk |
6464 file . write ( chunk )
6565 end
Original file line number Diff line number Diff line change 1+ require 'protocol/http/body/reader'
2+
3+ RSpec . describe Protocol ::HTTP ::Body ::Reader do
4+ class TestReader
5+ include Protocol ::HTTP ::Body ::Reader
6+
7+ def initialize ( body )
8+ @body = body
9+ end
10+ end
11+
12+ subject do
13+ TestReader . new ( %w( the quick brown fox ) )
14+ end
15+
16+ describe '#save' do
17+ let ( :path ) { File . expand_path ( 'reader_spec.txt' , __dir__ ) }
18+
19+ before do
20+ File . open ( path , 'w' ) { }
21+ end
22+
23+ it 'saves to the provided filename' do
24+ expect { subject . save ( path ) }
25+ . to change { File . read ( path ) }
26+ . from ( '' )
27+ . to ( 'thequickbrownfox' )
28+ end
29+
30+ it 'mirrors the interface of File.open' do
31+ expect { subject . save ( path , nil , mode : 'w' ) }
32+ . to change { File . read ( path ) }
33+ . from ( '' )
34+ . to ( 'thequickbrownfox' )
35+ end
36+ end
37+ end
You can’t perform that action at this time.
0 commit comments