diff options
Diffstat (limited to 'spec/rubyspec/library/etc')
-rw-r--r-- | spec/rubyspec/library/etc/endgrent_spec.rb | 7 | ||||
-rw-r--r-- | spec/rubyspec/library/etc/endpwent_spec.rb | 7 | ||||
-rw-r--r-- | spec/rubyspec/library/etc/getgrent_spec.rb | 7 | ||||
-rw-r--r-- | spec/rubyspec/library/etc/getgrgid_spec.rb | 70 | ||||
-rw-r--r-- | spec/rubyspec/library/etc/getgrnam_spec.rb | 30 | ||||
-rw-r--r-- | spec/rubyspec/library/etc/getlogin_spec.rb | 32 | ||||
-rw-r--r-- | spec/rubyspec/library/etc/getpwent_spec.rb | 7 | ||||
-rw-r--r-- | spec/rubyspec/library/etc/getpwnam_spec.rb | 28 | ||||
-rw-r--r-- | spec/rubyspec/library/etc/getpwuid_spec.rb | 36 | ||||
-rw-r--r-- | spec/rubyspec/library/etc/group_spec.rb | 18 | ||||
-rw-r--r-- | spec/rubyspec/library/etc/nprocessors_spec.rb | 11 | ||||
-rw-r--r-- | spec/rubyspec/library/etc/shared/windows.rb | 7 | ||||
-rw-r--r-- | spec/rubyspec/library/etc/struct_group_spec.rb | 31 | ||||
-rw-r--r-- | spec/rubyspec/library/etc/struct_passwd_spec.rb | 43 |
14 files changed, 0 insertions, 334 deletions
diff --git a/spec/rubyspec/library/etc/endgrent_spec.rb b/spec/rubyspec/library/etc/endgrent_spec.rb deleted file mode 100644 index 95f0dc05e3..0000000000 --- a/spec/rubyspec/library/etc/endgrent_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/windows', __FILE__) -require 'etc' - -describe "Etc.endgrent" do - it_behaves_like(:etc_on_windows, :endgrent) -end diff --git a/spec/rubyspec/library/etc/endpwent_spec.rb b/spec/rubyspec/library/etc/endpwent_spec.rb deleted file mode 100644 index 7ce8f1925b..0000000000 --- a/spec/rubyspec/library/etc/endpwent_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/windows', __FILE__) -require 'etc' - -describe "Etc.endpwent" do - it_behaves_like(:etc_on_windows, :endpwent) -end diff --git a/spec/rubyspec/library/etc/getgrent_spec.rb b/spec/rubyspec/library/etc/getgrent_spec.rb deleted file mode 100644 index 96225e351a..0000000000 --- a/spec/rubyspec/library/etc/getgrent_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/windows', __FILE__) -require 'etc' - -describe "Etc.getgrent" do - it_behaves_like(:etc_on_windows, :getgrent) -end diff --git a/spec/rubyspec/library/etc/getgrgid_spec.rb b/spec/rubyspec/library/etc/getgrgid_spec.rb deleted file mode 100644 index 9b6b283d52..0000000000 --- a/spec/rubyspec/library/etc/getgrgid_spec.rb +++ /dev/null @@ -1,70 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'etc' - -platform_is :windows do - describe "Etc.getgrgid" do - it "returns nil" do - Etc.getgrgid(1).should == nil - Etc.getgrgid(nil).should == nil - Etc.getgrgid('nil').should == nil - end - end -end - -# TODO: verify these on non-windows, non-darwin OS -platform_is_not :windows do - describe "Etc.getgrgid" do - before :all do - @gid = `id -g`.strip.to_i - @name = `id -gn`.strip - end - - it "returns a Etc::Group struct instance for the given user" do - gr = Etc.getgrgid(@gid) - - gr.is_a?(Etc::Group).should == true - gr.gid.should == @gid - gr.name.should == @name - end - - it "returns the Etc::Group for a given gid if it exists" do - grp = Etc.getgrgid(@gid) - grp.should be_kind_of(Etc::Group) - grp.gid.should == @gid - grp.name.should == @name - end - - it "uses Process.gid as the default value for the argument" do - gr = Etc.getgrgid - - gr.gid.should == @gid - gr.name.should == @name - end - - it "returns the Group for a given gid if it exists" do - grp = Etc.getgrgid(@gid) - grp.should be_kind_of(Struct::Group) - grp.gid.should == @gid - grp.name.should == @name - end - - it "raises if the group does not exist" do - lambda { Etc.getgrgid(9876)}.should raise_error(ArgumentError) - end - - it "raises a TypeError if not passed an Integer" do - lambda { Etc.getgrgid("foo") }.should raise_error(TypeError) - lambda { Etc.getgrgid(nil) }.should raise_error(TypeError) - end - - it "can be called safely by multiple threads" do - 20.times.map do - Thread.new do - 100.times do - Etc.getgrgid(@gid).gid.should == @gid - end - end - end.each(&:join) - end - end -end diff --git a/spec/rubyspec/library/etc/getgrnam_spec.rb b/spec/rubyspec/library/etc/getgrnam_spec.rb deleted file mode 100644 index 46193f49d6..0000000000 --- a/spec/rubyspec/library/etc/getgrnam_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'etc' - -platform_is :windows do - describe "Etc.getgrnam" do - it "returns nil" do - Etc.getgrnam(1).should == nil - Etc.getgrnam(nil).should == nil - Etc.getgrnam('nil').should == nil - end - end -end - -platform_is_not :windows do - describe "Etc.getgrnam" do - it "returns a Etc::Group struct instance for the given group" do - gr_name = Etc.getgrent.name - Etc.endgrent - gr = Etc.getgrnam(gr_name) - gr.is_a?(Etc::Group).should == true - end - - it "only accepts strings as argument" do - lambda { - Etc.getgrnam(123) - Etc.getgrnam(nil) - }.should raise_error(TypeError) - end - end -end diff --git a/spec/rubyspec/library/etc/getlogin_spec.rb b/spec/rubyspec/library/etc/getlogin_spec.rb deleted file mode 100644 index ae52942a92..0000000000 --- a/spec/rubyspec/library/etc/getlogin_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'etc' - -describe "Etc.getlogin" do - it "returns the name associated with the current login activity" do - getlogin_null = false - - # POSIX logname(1) shows getlogin(2)'s result - # NOTE: Etc.getlogin returns ENV['USER'] if getlogin(2) returns NULL - begin - # make Etc.getlogin to return nil if getlogin(3) returns NULL - envuser, ENV['USER'] = ENV['USER'], nil - if Etc.getlogin - # Etc.getlogin returns the same result of logname(2) - # if it returns non NULL - Etc.getlogin.should == `id -un`.chomp - else - # Etc.getlogin may return nil if the login name is not set - # because of chroot or sudo or something. - Etc.getlogin.should be_nil - getlogin_null = true - end - ensure - ENV['USER'] = envuser - end - - # if getlogin(2) returns NULL, Etc.getlogin returns ENV['USER'] - if getlogin_null - Etc.getlogin.should == ENV['USER'] - end - end -end diff --git a/spec/rubyspec/library/etc/getpwent_spec.rb b/spec/rubyspec/library/etc/getpwent_spec.rb deleted file mode 100644 index 1c8057c9e5..0000000000 --- a/spec/rubyspec/library/etc/getpwent_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/windows', __FILE__) -require 'etc' - -describe "Etc.getpwent" do - it_behaves_like(:etc_on_windows, :getpwent) -end diff --git a/spec/rubyspec/library/etc/getpwnam_spec.rb b/spec/rubyspec/library/etc/getpwnam_spec.rb deleted file mode 100644 index 8610b5da91..0000000000 --- a/spec/rubyspec/library/etc/getpwnam_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'etc' - -platform_is :windows do - describe "Etc.getpwnam" do - it "returns nil" do - Etc.getpwnam(1).should == nil - Etc.getpwnam(nil).should == nil - Etc.getpwnam('nil').should == nil - end - end -end - -platform_is_not :windows do - describe "Etc.getpwnam" do - it "returns a Etc::Passwd struct instance for the given user" do - pw = Etc.getpwnam(`whoami`.strip) - pw.is_a?(Etc::Passwd).should == true - end - - it "only accepts strings as argument" do - lambda { - Etc.getpwnam(123) - Etc.getpwnam(nil) - }.should raise_error(TypeError) - end - end -end diff --git a/spec/rubyspec/library/etc/getpwuid_spec.rb b/spec/rubyspec/library/etc/getpwuid_spec.rb deleted file mode 100644 index f1c7218c0b..0000000000 --- a/spec/rubyspec/library/etc/getpwuid_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'etc' - -platform_is :windows do - describe "Etc.getpwuid" do - it "returns nil" do - Etc.getpwuid(1).should == nil - Etc.getpwuid(nil).should == nil - Etc.getpwuid('nil').should == nil - end - end -end - -platform_is_not :windows do - describe "Etc.getpwuid" do - before :all do - @pw = Etc.getpwuid(`id -u`.strip.to_i) - end - - it "returns a Etc::Passwd struct instance for the given user" do - @pw.is_a?(Etc::Passwd).should == true - end - - it "uses Process.uid as the default value for the argument" do - pw = Etc.getpwuid - pw.should == @pw - end - - it "only accepts integers as argument" do - lambda { - Etc.getpwuid("foo") - Etc.getpwuid(nil) - }.should raise_error(TypeError) - end - end -end diff --git a/spec/rubyspec/library/etc/group_spec.rb b/spec/rubyspec/library/etc/group_spec.rb deleted file mode 100644 index 8b92cb7bf0..0000000000 --- a/spec/rubyspec/library/etc/group_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/windows', __FILE__) -require 'etc' - -describe "Etc.group" do - it_behaves_like(:etc_on_windows, :group) - - platform_is_not :windows do - it "raises a RuntimeError for parallel iteration" do - proc { - Etc.group do | group | - Etc.group do | group2 | - end - end - }.should raise_error(RuntimeError) - end - end -end diff --git a/spec/rubyspec/library/etc/nprocessors_spec.rb b/spec/rubyspec/library/etc/nprocessors_spec.rb deleted file mode 100644 index bce11d06c5..0000000000 --- a/spec/rubyspec/library/etc/nprocessors_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'etc' - -ruby_version_is "2.2" do - describe "Etc.nprocessors" do - it "returns the number of online processors" do - Etc.nprocessors.should be_kind_of(Integer) - Etc.nprocessors.should >= 1 - end - end -end diff --git a/spec/rubyspec/library/etc/shared/windows.rb b/spec/rubyspec/library/etc/shared/windows.rb deleted file mode 100644 index 8bae235199..0000000000 --- a/spec/rubyspec/library/etc/shared/windows.rb +++ /dev/null @@ -1,7 +0,0 @@ -describe :etc_on_windows, shared: true do - platform_is :windows do - it "returns nil" do - Etc.send(@method).should == nil - end - end -end diff --git a/spec/rubyspec/library/etc/struct_group_spec.rb b/spec/rubyspec/library/etc/struct_group_spec.rb deleted file mode 100644 index c33a177a98..0000000000 --- a/spec/rubyspec/library/etc/struct_group_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'etc' - -describe "Struct::Group" do - platform_is_not :windows do - before :all do - @g = Etc.getgrgid(`id -g`.strip.to_i) - end - - it "returns group name" do - @g.name.should == `id -gn`.strip - end - - it "returns group password" do - @g.passwd.is_a?(String).should == true - end - - it "returns group id" do - @g.gid.should == `id -g`.strip.to_i - end - - it "returns an array of users belonging to the group" do - @g.mem.is_a?(Array).should == true - end - - it "can be compared to another object" do - (@g == nil).should == false - (@g == Object.new).should == false - end - end -end diff --git a/spec/rubyspec/library/etc/struct_passwd_spec.rb b/spec/rubyspec/library/etc/struct_passwd_spec.rb deleted file mode 100644 index 3e4bfee828..0000000000 --- a/spec/rubyspec/library/etc/struct_passwd_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'etc' - -describe "Struct::Passwd" do - platform_is_not :windows do - before :all do - @pw = Etc.getpwuid(`id -u`.strip.to_i) - end - - it "returns user name" do - @pw.name.should == `id -un`.strip - end - - it "returns user password" do - @pw.passwd.is_a?(String).should == true - end - - it "returns user id" do - @pw.uid.should == `id -u`.strip.to_i - end - - it "returns user group id" do - @pw.gid.should == `id -g`.strip.to_i - end - - it "returns user personal information (gecos field)" do - @pw.gecos.is_a?(String).should == true - end - - it "returns user home directory" do - @pw.dir.is_a?(String).should == true - end - - it "returns user shell" do - @pw.shell.is_a?(String).should == true - end - - it "can be compared to another object" do - (@pw == nil).should == false - (@pw == Object.new).should == false - end - end -end |