Skip to content

Commit 8e48081

Browse files
misdorobblimke
authored andcommitted
Rewrite patron spec to stub file open call instead of mangling file permissions
1 parent f716f08 commit 8e48081

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

spec/acceptance/patron/patron_spec.rb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,14 @@
4444

4545
it "should raise same error as Patron if file is not readable for get request" do
4646
stub_request(:get, "www.example.com")
47-
File.open("/tmp/read_only_file", "w") do |tmpfile|
48-
tmpfile.chmod(0400)
49-
end
50-
begin
51-
expect {
52-
@sess.get_file("/", "/tmp/read_only_file")
53-
}.to raise_error(ArgumentError, "Unable to open specified file.")
54-
ensure
55-
File.unlink("/tmp/read_only_file")
56-
end
47+
48+
allow(File).to receive(:open).and_call_original
49+
allow(File).to receive(:open).with(@file_path, "w").and_raise(Errno::EACCES)
50+
51+
expect {
52+
@sess.get_file("/", @file_path)
53+
}.to raise_error(ArgumentError, "Unable to open specified file.")
54+
5755
end
5856

5957
it "should work with put_file" do

0 commit comments

Comments
 (0)