summaryrefslogtreecommitdiff
path: root/spec/ruby/library/etc/getgrnam_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/etc/getgrnam_spec.rb')
-rw-r--r--spec/ruby/library/etc/getgrnam_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/ruby/library/etc/getgrnam_spec.rb b/spec/ruby/library/etc/getgrnam_spec.rb
new file mode 100644
index 0000000000..325ea7b297
--- /dev/null
+++ b/spec/ruby/library/etc/getgrnam_spec.rb
@@ -0,0 +1,30 @@
+require_relative '../../spec_helper'
+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, :android 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
+ -> {
+ Etc.getgrnam(123)
+ Etc.getgrnam(nil)
+ }.should.raise(TypeError)
+ end
+ end
+end