summaryrefslogtreecommitdiff
path: root/spec/ruby/core/file
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-10 13:30:25 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-10 13:30:25 +0000
commit205f0dcf3aafffc1f7a26628845bf6e1b71441da (patch)
tree8a045cddde19a309a4b2c149e320bf9dc00a0cd6 /spec/ruby/core/file
parent5d0103f9731f54285fe716137697cea7c0cfd3ab (diff)
spec/: skip some specs so that no failure occurs in root privilege
Follow up of r61757, This change makes `sudo make test-spec` pass on my machine. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/file')
-rw-r--r--spec/ruby/core/file/chmod_spec.rb102
-rw-r--r--spec/ruby/core/file/open_spec.rb32
-rw-r--r--spec/ruby/core/file/owned_spec.rb8
-rw-r--r--spec/ruby/core/file/stat/owned_spec.rb10
4 files changed, 84 insertions, 68 deletions
diff --git a/spec/ruby/core/file/chmod_spec.rb b/spec/ruby/core/file/chmod_spec.rb
index 8590f3008d..a741ebb966 100644
--- a/spec/ruby/core/file/chmod_spec.rb
+++ b/spec/ruby/core/file/chmod_spec.rb
@@ -71,37 +71,39 @@ describe "File#chmod" do
end
platform_is_not :windows do
- it "with '0222' makes file writable but not readable or executable" do
- @file.chmod(0222)
- File.readable?(@filename).should == false
- File.writable?(@filename).should == true
- File.executable?(@filename).should == false
- end
-
- it "with '0444' makes file readable but not writable or executable" do
- @file.chmod(0444)
- File.readable?(@filename).should == true
- File.writable?(@filename).should == false
- File.executable?(@filename).should == false
- end
-
- it "with '0666' makes file readable and writable but not executable" do
- @file.chmod(0666)
- File.readable?(@filename).should == true
- File.writable?(@filename).should == true
- File.executable?(@filename).should == false
- end
-
- it "with '0111' makes file executable but not readable or writable" do
- @file.chmod(0111)
- File.readable?(@filename).should == false
- File.writable?(@filename).should == false
- File.executable?(@filename).should == true
- end
-
- it "modifies the permission bits of the files specified" do
- @file.chmod(0755)
- File.stat(@filename).mode.should == 33261
+ as_user do
+ it "with '0222' makes file writable but not readable or executable" do
+ @file.chmod(0222)
+ File.readable?(@filename).should == false
+ File.writable?(@filename).should == true
+ File.executable?(@filename).should == false
+ end
+
+ it "with '0444' makes file readable but not writable or executable" do
+ @file.chmod(0444)
+ File.readable?(@filename).should == true
+ File.writable?(@filename).should == false
+ File.executable?(@filename).should == false
+ end
+
+ it "with '0666' makes file readable and writable but not executable" do
+ @file.chmod(0666)
+ File.readable?(@filename).should == true
+ File.writable?(@filename).should == true
+ File.executable?(@filename).should == false
+ end
+
+ it "with '0111' makes file executable but not readable or writable" do
+ @file.chmod(0111)
+ File.readable?(@filename).should == false
+ File.writable?(@filename).should == false
+ File.executable?(@filename).should == true
+ end
+
+ it "modifies the permission bits of the files specified" do
+ @file.chmod(0755)
+ File.stat(@filename).mode.should == 33261
+ end
end
end
end
@@ -204,18 +206,20 @@ describe "File.chmod" do
end
platform_is_not :windows do
- it "with '0222' makes file writable but not readable or executable" do
- File.chmod(0222, @file)
- File.readable?(@file).should == false
- File.writable?(@file).should == true
- File.executable?(@file).should == false
- end
-
- it "with '0444' makes file readable but not writable or executable" do
- File.chmod(0444, @file)
- File.readable?(@file).should == true
- File.writable?(@file).should == false
- File.executable?(@file).should == false
+ as_user do
+ it "with '0222' makes file writable but not readable or executable" do
+ File.chmod(0222, @file)
+ File.readable?(@file).should == false
+ File.writable?(@file).should == true
+ File.executable?(@file).should == false
+ end
+
+ it "with '0444' makes file readable but not writable or executable" do
+ File.chmod(0444, @file)
+ File.readable?(@file).should == true
+ File.writable?(@file).should == false
+ File.executable?(@file).should == false
+ end
end
it "with '0666' makes file readable and writable but not executable" do
@@ -225,11 +229,13 @@ describe "File.chmod" do
File.executable?(@file).should == false
end
- it "with '0111' makes file executable but not readable or writable" do
- File.chmod(0111, @file)
- File.readable?(@file).should == false
- File.writable?(@file).should == false
- File.executable?(@file).should == true
+ as_user do
+ it "with '0111' makes file executable but not readable or writable" do
+ File.chmod(0111, @file)
+ File.readable?(@file).should == false
+ File.writable?(@file).should == false
+ File.executable?(@file).should == true
+ end
end
it "modifies the permission bits of the files specified" do
diff --git a/spec/ruby/core/file/open_spec.rb b/spec/ruby/core/file/open_spec.rb
index 440921a796..9d0ef62939 100644
--- a/spec/ruby/core/file/open_spec.rb
+++ b/spec/ruby/core/file/open_spec.rb
@@ -147,11 +147,13 @@ describe "File.open" do
end
platform_is_not :windows do
- it "creates a new write-only file when invoked with 'w' and '0222'" do
- rm_r @file
- File.open(@file, 'w', 0222) {}
- File.readable?(@file).should == false
- File.writable?(@file).should == true
+ as_user do
+ it "creates a new write-only file when invoked with 'w' and '0222'" do
+ rm_r @file
+ File.open(@file, 'w', 0222) {}
+ File.readable?(@file).should == false
+ File.writable?(@file).should == true
+ end
end
end
@@ -464,17 +466,21 @@ describe "File.open" do
end
platform_is_not :windows do
- it "raises an Errno::EACCES when opening non-permitted file" do
- @fh = File.open(@file, "w")
- @fh.chmod(000)
- lambda { fh1 = File.open(@file); fh1.close }.should raise_error(Errno::EACCES)
+ as_user do
+ it "raises an Errno::EACCES when opening non-permitted file" do
+ @fh = File.open(@file, "w")
+ @fh.chmod(000)
+ lambda { fh1 = File.open(@file); fh1.close }.should raise_error(Errno::EACCES)
+ end
end
end
- it "raises an Errno::EACCES when opening read-only file" do
- @fh = File.open(@file, "w")
- @fh.chmod(0444)
- lambda { File.open(@file, "w") }.should raise_error(Errno::EACCES)
+ as_user do
+ it "raises an Errno::EACCES when opening read-only file" do
+ @fh = File.open(@file, "w")
+ @fh.chmod(0444)
+ lambda { File.open(@file, "w") }.should raise_error(Errno::EACCES)
+ end
end
it "opens a file for binary read" do
diff --git a/spec/ruby/core/file/owned_spec.rb b/spec/ruby/core/file/owned_spec.rb
index d19e9cb278..c2d8a74b49 100644
--- a/spec/ruby/core/file/owned_spec.rb
+++ b/spec/ruby/core/file/owned_spec.rb
@@ -24,9 +24,11 @@ describe "File.owned?" do
end
platform_is_not :windows do
- it "returns false when the file is not owned by the user" do
- system_file = '/etc/passwd'
- File.owned?(system_file).should == false
+ as_user do
+ it "returns false when the file is not owned by the user" do
+ system_file = '/etc/passwd'
+ File.owned?(system_file).should == false
+ end
end
end
diff --git a/spec/ruby/core/file/stat/owned_spec.rb b/spec/ruby/core/file/stat/owned_spec.rb
index 4c4d843bbe..f321aefe7a 100644
--- a/spec/ruby/core/file/stat/owned_spec.rb
+++ b/spec/ruby/core/file/stat/owned_spec.rb
@@ -22,10 +22,12 @@ describe "File::Stat#owned?" do
end
platform_is_not :windows do
- it "returns false if the file is not owned by the user" do
- system_file = '/etc/passwd'
- st = File.stat(system_file)
- st.owned?.should == false
+ as_user do
+ it "returns false if the file is not owned by the user" do
+ system_file = '/etc/passwd'
+ st = File.stat(system_file)
+ st.owned?.should == false
+ end
end
end
end