From 5cb0da475e64139a345ad28ef3fcd58dcffd88c5 Mon Sep 17 00:00:00 2001 From: Larry Gilbert Date: Thu, 1 Aug 2013 12:02:15 -0700 Subject: [PATCH] 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. --- spec/request2_spec.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/spec/request2_spec.rb b/spec/request2_spec.rb index c97ccb2..b3fbe65 100644 --- a/spec/request2_spec.rb +++ b/spec/request2_spec.rb @@ -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 \ No newline at end of file