Skip to content

Commit

Permalink
Fix patron specs for #post_file and #get_file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
grig committed Mar 7, 2011
1 parent 7426af2 commit d85b8b0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions spec/patron_spec.rb
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit d85b8b0

Please sign in to comment.