Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit d85b8b00093112ef1ee4b84968f50bdf132ab2ff 1 parent 7426af2
@grig authored
Showing with 11 additions and 4 deletions.
  1. +11 −4 spec/patron_spec.rb
View
15 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
Please sign in to comment.
Something went wrong with that request. Please try again.