1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

Use IO#closed? instead of temp file count to test file closure in spec

Hopefully this takes care of the spurious spec failures described in
issue #163.
This commit is contained in:
Larry Gilbert 2013-08-01 12:02:15 -07:00
parent 24273a2423
commit 5cb0da475e

View file

@ -25,16 +25,11 @@ describe RestClient::Request do
it 'closes payload if not nil' do
test_file = File.new(File.join( File.dirname(File.expand_path(__FILE__)), 'master_shake.jpg'))
initial_count = tmp_count
stub_request(:post, 'http://some/resource').with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate'}).to_return(:body => 'foo', :status => 200)
RestClient::Request.execute(:url => 'http://some/resource', :method => :post, :payload => {:file => test_file})
tmp_count.should == initial_count
test_file.closed?.should be_true
end
end
def tmp_count
Dir.glob(Dir::tmpdir + "/*").size
end