From d85b8b00093112ef1ee4b84968f50bdf132ab2ff Mon Sep 17 00:00:00 2001 From: Alex Grigorovich Date: Sun, 6 Mar 2011 22:54:21 +0600 Subject: [PATCH] Fix patron specs for #post_file and #get_file patron_spec.rb: specs fail when / is actually writable by the user (which happens to be the case on Mac OS X). A file "/non_existing_file" actually gets created in a spec for #get_file. A spec for #post_file then expects that file to not be present and fails. --- spec/patron_spec.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/spec/patron_spec.rb b/spec/patron_spec.rb index 58a705516..cbcb59c87 100644 --- a/spec/patron_spec.rb +++ b/spec/patron_spec.rb @@ -38,9 +38,16 @@ it "should raise same error as Patron if file is not readable for get request" do stub_http_request(:get, "www.example.com") - lambda { - @sess.get_file("/", "/non_existing_file") - }.should raise_error(ArgumentError, "Unable to open specified file.") + File.open("/tmp/read_only_file", "w") do |tmpfile| + tmpfile.chmod(0400) + end + begin + lambda { + @sess.get_file("/", "/tmp/read_only_file") + }.should raise_error(ArgumentError, "Unable to open specified file.") + ensure + File.unlink("/tmp/read_only_file") + end end it "should work with put_file" do @@ -58,7 +65,7 @@ it "should raise same error as Patron if file is not readable for post request" do stub_http_request(:post, "www.example.com").with(:body => "abc") lambda { - @sess.post_file("/", "/non_existing_file") + @sess.post_file("/", "/path/to/non/existing/file") }.should raise_error(ArgumentError, "Unable to open specified file.") end