diff options
Diffstat (limited to 'spec/ruby/library')
-rw-r--r-- | spec/ruby/library/bigdecimal/exponent_spec.rb | 11 | ||||
-rw-r--r-- | spec/ruby/library/fiddle/handle/initialize_spec.rb | 10 | ||||
-rw-r--r-- | spec/ruby/library/io-wait/wait_readable_spec.rb | 25 | ||||
-rw-r--r-- | spec/ruby/library/io-wait/wait_writable_spec.rb | 18 | ||||
-rw-r--r-- | spec/ruby/library/socket/addrinfo/initialize_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/library/socket/shared/pack_sockaddr.rb | 5 |
6 files changed, 59 insertions, 12 deletions
diff --git a/spec/ruby/library/bigdecimal/exponent_spec.rb b/spec/ruby/library/bigdecimal/exponent_spec.rb index f63c4e5798..8877147955 100644 --- a/spec/ruby/library/bigdecimal/exponent_spec.rb +++ b/spec/ruby/library/bigdecimal/exponent_spec.rb @@ -18,17 +18,6 @@ describe "BigDecimal#exponent" do BigDecimal("1234567E10").exponent.should == 17 end -# commenting this spec out after discussion with Defiler, since it seems to be an MRI bug, not a real feature -=begin - platform_is wordsize: 32 do - # TODO: write specs for both 32 and 64 bit - it "returns 0 if exponent can't be represented as Integer" do - BigDecimal("2E1000000000000000").exponent.should == 0 - BigDecimal("-5E-999999999999999").exponent.should == 0 - end - end -=end - it "returns 0 if self is 0" do BigDecimal("0").exponent.should == 0 BigDecimal("+0").exponent.should == 0 diff --git a/spec/ruby/library/fiddle/handle/initialize_spec.rb b/spec/ruby/library/fiddle/handle/initialize_spec.rb new file mode 100644 index 0000000000..51c2470efd --- /dev/null +++ b/spec/ruby/library/fiddle/handle/initialize_spec.rb @@ -0,0 +1,10 @@ +require_relative '../../../spec_helper' +require 'fiddle' + +describe "Fiddle::Handle#initialize" do + it "raises Fiddle::DLError if the library cannot be found" do + -> { + Fiddle::Handle.new("doesnotexist.doesnotexist") + }.should raise_error(Fiddle::DLError) + end +end diff --git a/spec/ruby/library/io-wait/wait_readable_spec.rb b/spec/ruby/library/io-wait/wait_readable_spec.rb new file mode 100644 index 0000000000..48e0b4ef7d --- /dev/null +++ b/spec/ruby/library/io-wait/wait_readable_spec.rb @@ -0,0 +1,25 @@ +require_relative '../../spec_helper' + +require 'io/wait' + +describe "IO#wait_readable" do + before :each do + @io = File.new(__FILE__ ) + end + + after :each do + @io.close + end + + it "waits for the IO to become readable with no timeout" do + @io.wait_readable.should == @io + end + + it "waits for the IO to become readable with the given timeout" do + @io.wait_readable(1).should == @io + end + + it "waits for the IO to become readable with the given large timeout" do + @io.wait_readable(365 * 24 * 60 * 60).should == @io + end +end diff --git a/spec/ruby/library/io-wait/wait_writable_spec.rb b/spec/ruby/library/io-wait/wait_writable_spec.rb new file mode 100644 index 0000000000..5900a0c566 --- /dev/null +++ b/spec/ruby/library/io-wait/wait_writable_spec.rb @@ -0,0 +1,18 @@ +require_relative '../../spec_helper' + +require 'io/wait' + +describe "IO#wait_writable" do + it "waits for the IO to become writable with no timeout" do + STDOUT.wait_writable.should == STDOUT + end + + it "waits for the IO to become writable with the given timeout" do + STDOUT.wait_writable(1).should == STDOUT + end + + it "waits for the IO to become writable with the given large timeout" do + # Represents one year and is larger than a 32-bit int + STDOUT.wait_writable(365 * 24 * 60 * 60).should == STDOUT + end +end diff --git a/spec/ruby/library/socket/addrinfo/initialize_spec.rb b/spec/ruby/library/socket/addrinfo/initialize_spec.rb index 00250439fd..83b204b575 100644 --- a/spec/ruby/library/socket/addrinfo/initialize_spec.rb +++ b/spec/ruby/library/socket/addrinfo/initialize_spec.rb @@ -91,7 +91,7 @@ describe "Addrinfo#initialize" do @addrinfo.afamily.should == Socket::AF_INET6 end - it "returns the 0 socket type" do + it "returns the specified socket type" do @addrinfo.socktype.should == Socket::SOCK_STREAM end diff --git a/spec/ruby/library/socket/shared/pack_sockaddr.rb b/spec/ruby/library/socket/shared/pack_sockaddr.rb index 2df09027c9..ca823742cb 100644 --- a/spec/ruby/library/socket/shared/pack_sockaddr.rb +++ b/spec/ruby/library/socket/shared/pack_sockaddr.rb @@ -19,6 +19,11 @@ describe :socket_pack_sockaddr_in, shared: true do Socket.unpack_sockaddr_in(sockaddr_in).should == [0, '127.0.0.1'] end + it 'resolves the service name to a port' do + sockaddr_in = Socket.public_send(@method, 'http', '127.0.0.1') + Socket.unpack_sockaddr_in(sockaddr_in).should == [80, '127.0.0.1'] + end + describe 'using an IPv4 address' do it 'returns a String of 16 bytes' do str = Socket.public_send(@method, 80, '127.0.0.1') |