diff options
Diffstat (limited to 'spec/ruby/library')
-rw-r--r-- | spec/ruby/library/etc/confstr_spec.rb | 14 | ||||
-rw-r--r-- | spec/ruby/library/etc/group_spec.rb | 9 | ||||
-rw-r--r-- | spec/ruby/library/etc/passwd_spec.rb | 15 | ||||
-rw-r--r-- | spec/ruby/library/etc/sysconf_spec.rb | 31 | ||||
-rw-r--r-- | spec/ruby/library/etc/sysconfdir_spec.rb | 8 | ||||
-rw-r--r-- | spec/ruby/library/etc/systmpdir_spec.rb | 8 | ||||
-rw-r--r-- | spec/ruby/library/socket/basicsocket/connect_address_spec.rb | 58 | ||||
-rw-r--r-- | spec/ruby/library/socket/fixtures/classes.rb | 2 |
8 files changed, 116 insertions, 29 deletions
diff --git a/spec/ruby/library/etc/confstr_spec.rb b/spec/ruby/library/etc/confstr_spec.rb new file mode 100644 index 0000000000..0c922a3a77 --- /dev/null +++ b/spec/ruby/library/etc/confstr_spec.rb @@ -0,0 +1,14 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'etc' + +platform_is_not :windows do + describe "Etc.confstr" do + it "returns a String for Etc::CS_PATH" do + Etc.confstr(Etc::CS_PATH).should be_an_instance_of(String) + end + + it "raises Errno::EINVAL for unknown configuration variables" do + -> { Etc.confstr(-1) }.should raise_error(Errno::EINVAL) + end + end +end diff --git a/spec/ruby/library/etc/group_spec.rb b/spec/ruby/library/etc/group_spec.rb index 1524454333..fdd39bda16 100644 --- a/spec/ruby/library/etc/group_spec.rb +++ b/spec/ruby/library/etc/group_spec.rb @@ -6,6 +6,15 @@ describe "Etc.group" do it_behaves_like :etc_on_windows, :group platform_is_not :windows do + it "returns a Etc::Group struct" do + group = Etc.group + begin + group.should be_an_instance_of(Etc::Group) + ensure + Etc.endgrent + end + end + it "raises a RuntimeError for parallel iteration" do proc { Etc.group do | group | diff --git a/spec/ruby/library/etc/passwd_spec.rb b/spec/ruby/library/etc/passwd_spec.rb new file mode 100644 index 0000000000..d61dada451 --- /dev/null +++ b/spec/ruby/library/etc/passwd_spec.rb @@ -0,0 +1,15 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'etc' + +platform_is_not :windows do + describe "Etc.passwd" do + it "returns a Etc::Passwd struct" do + passwd = Etc.passwd + begin + passwd.should be_an_instance_of(Etc::Passwd) + ensure + Etc.endpwent + end + end + end +end diff --git a/spec/ruby/library/etc/sysconf_spec.rb b/spec/ruby/library/etc/sysconf_spec.rb new file mode 100644 index 0000000000..34dcf6e470 --- /dev/null +++ b/spec/ruby/library/etc/sysconf_spec.rb @@ -0,0 +1,31 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'etc' + +platform_is_not :windows do + describe "Etc.sysconf" do + def should_be_integer_or_nil(value) + if value.nil? + value.should == nil + else + value.should be_kind_of(Integer) + end + end + + it "returns the value of POSIX.1 system configuration variables" do + Etc.sysconf(Etc::SC_ARG_MAX).should be_kind_of(Integer) + should_be_integer_or_nil(Etc.sysconf(Etc::SC_CHILD_MAX)) + Etc.sysconf(Etc::SC_HOST_NAME_MAX).should be_kind_of(Integer) + Etc.sysconf(Etc::SC_LOGIN_NAME_MAX).should be_kind_of(Integer) + Etc.sysconf(Etc::SC_NGROUPS_MAX).should be_kind_of(Integer) + Etc.sysconf(Etc::SC_CLK_TCK).should be_kind_of(Integer) + Etc.sysconf(Etc::SC_OPEN_MAX).should be_kind_of(Integer) + Etc.sysconf(Etc::SC_PAGESIZE).should be_kind_of(Integer) + Etc.sysconf(Etc::SC_RE_DUP_MAX).should be_kind_of(Integer) + Etc.sysconf(Etc::SC_STREAM_MAX).should be_kind_of(Integer) + should_be_integer_or_nil(Etc.sysconf(Etc::SC_SYMLOOP_MAX)) + Etc.sysconf(Etc::SC_TTY_NAME_MAX).should be_kind_of(Integer) + Etc.sysconf(Etc::SC_TZNAME_MAX).should be_kind_of(Integer) + Etc.sysconf(Etc::SC_VERSION).should be_kind_of(Integer) + end + end +end diff --git a/spec/ruby/library/etc/sysconfdir_spec.rb b/spec/ruby/library/etc/sysconfdir_spec.rb new file mode 100644 index 0000000000..d54299c513 --- /dev/null +++ b/spec/ruby/library/etc/sysconfdir_spec.rb @@ -0,0 +1,8 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'etc' + +describe "Etc.sysconfdir" do + it "returns a String" do + Etc.sysconfdir.should be_an_instance_of(String) + end +end diff --git a/spec/ruby/library/etc/systmpdir_spec.rb b/spec/ruby/library/etc/systmpdir_spec.rb new file mode 100644 index 0000000000..99c82903f8 --- /dev/null +++ b/spec/ruby/library/etc/systmpdir_spec.rb @@ -0,0 +1,8 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'etc' + +describe "Etc.systmpdir" do + it "returns a String" do + Etc.systmpdir.should be_an_instance_of(String) + end +end diff --git a/spec/ruby/library/socket/basicsocket/connect_address_spec.rb b/spec/ruby/library/socket/basicsocket/connect_address_spec.rb index cb05d3bfe1..03e456b620 100644 --- a/spec/ruby/library/socket/basicsocket/connect_address_spec.rb +++ b/spec/ruby/library/socket/basicsocket/connect_address_spec.rb @@ -53,42 +53,44 @@ describe 'Socket#connect_address' do end end - describe 'using a socket bound to ::' do - before do - @sock = Socket.new(:INET6, :STREAM) - @sock.bind(Socket.sockaddr_in(0, '::')) - end + guard -> { SocketSpecs.ipv6_available? } do + describe 'using a socket bound to ::' do + before do + @sock = Socket.new(:INET6, :STREAM) + @sock.bind(Socket.sockaddr_in(0, '::')) + end - after do - @sock.close - end + after do + @sock.close + end - it 'returns an Addrinfo' do - @sock.connect_address.should be_an_instance_of(Addrinfo) - end + it 'returns an Addrinfo' do + @sock.connect_address.should be_an_instance_of(Addrinfo) + end - it 'uses ::1 as the IP address' do - @sock.connect_address.ip_address.should == '::1' - end + it 'uses ::1 as the IP address' do + @sock.connect_address.ip_address.should == '::1' + end - it 'uses the correct port number' do - @sock.connect_address.ip_port.should > 0 - end + it 'uses the correct port number' do + @sock.connect_address.ip_port.should > 0 + end - it 'uses AF_INET6 as the address family' do - @sock.connect_address.afamily.should == Socket::AF_INET6 - end + it 'uses AF_INET6 as the address family' do + @sock.connect_address.afamily.should == Socket::AF_INET6 + end - it 'uses PF_INET6 as the address family' do - @sock.connect_address.pfamily.should == Socket::PF_INET6 - end + it 'uses PF_INET6 as the address family' do + @sock.connect_address.pfamily.should == Socket::PF_INET6 + end - it 'uses SOCK_STREAM as the socket type' do - @sock.connect_address.socktype.should == Socket::SOCK_STREAM - end + it 'uses SOCK_STREAM as the socket type' do + @sock.connect_address.socktype.should == Socket::SOCK_STREAM + end - it 'uses 0 as the protocol' do - @sock.connect_address.protocol.should == 0 + it 'uses 0 as the protocol' do + @sock.connect_address.protocol.should == 0 + end end end diff --git a/spec/ruby/library/socket/fixtures/classes.rb b/spec/ruby/library/socket/fixtures/classes.rb index 1098b04a5e..8167b879fd 100644 --- a/spec/ruby/library/socket/fixtures/classes.rb +++ b/spec/ruby/library/socket/fixtures/classes.rb @@ -50,7 +50,7 @@ module SocketSpecs def self.ipv6_available? @ipv6_available ||= begin server = TCPServer.new('::1', 0) - rescue Errno::EADDRNOTAVAIL + rescue Errno::EADDRNOTAVAIL, SocketError :no else server.close |