1describe :file_writable, shared: true do 2 before :each do 3 @file = tmp('i_exist') 4 end 5 6 after :each do 7 rm_r @file 8 end 9 10 it "returns true if named file is writable by the effective user id of the process, otherwise false" do 11 platform_is_not :windows do 12 as_user do 13 @object.send(@method, "/etc/passwd").should == false 14 end 15 end 16 File.open(@file,'w') { @object.send(@method, @file).should == true } 17 end 18 19 it "accepts an object that has a #to_path method" do 20 File.open(@file,'w') { @object.send(@method, mock_to_path(@file)).should == true } 21 end 22end 23 24describe :file_writable_missing, shared: true do 25 it "returns false if the file does not exist" do 26 @object.send(@method, 'fake_file').should == false 27 end 28end 29