diff options
Diffstat (limited to 'spec/ruby/library/ipaddr')
| -rw-r--r-- | spec/ruby/library/ipaddr/new_spec.rb | 46 | ||||
| -rw-r--r-- | spec/ruby/library/ipaddr/operator_spec.rb | 16 | ||||
| -rw-r--r-- | spec/ruby/library/ipaddr/reverse_spec.rb | 4 |
3 files changed, 24 insertions, 42 deletions
diff --git a/spec/ruby/library/ipaddr/new_spec.rb b/spec/ruby/library/ipaddr/new_spec.rb index 053928c3cf..7fba2b372e 100644 --- a/spec/ruby/library/ipaddr/new_spec.rb +++ b/spec/ruby/library/ipaddr/new_spec.rb @@ -3,9 +3,9 @@ require 'ipaddr' describe "IPAddr#new" do it "initializes IPAddr" do - ->{ IPAddr.new("3FFE:505:ffff::/48") }.should_not raise_error - ->{ IPAddr.new("0:0:0:1::") }.should_not raise_error - ->{ IPAddr.new("2001:200:300::/48") }.should_not raise_error + ->{ IPAddr.new("3FFE:505:ffff::/48") }.should_not.raise + ->{ IPAddr.new("0:0:0:1::") }.should_not.raise + ->{ IPAddr.new("2001:200:300::/48") }.should_not.raise end it "initializes IPAddr ipv6 address with short notation" do @@ -77,34 +77,16 @@ describe "IPAddr#new" do a.family.should == Socket::AF_INET6 end - ruby_version_is ""..."3.1" do - it "raises on incorrect IPAddr strings" do - [ - ["fe80::1%fxp0"], - ["::1/255.255.255.0"], - [IPAddr.new("::1").to_i], - ["::ffff:192.168.1.2/120", Socket::AF_INET], - ["[192.168.1.2]/120"], - ].each { |args| - ->{ - IPAddr.new(*args) - }.should raise_error(ArgumentError) - } - end - end - - ruby_version_is "3.1" do - it "raises on incorrect IPAddr strings" do - [ - ["::1/255.255.255.0"], - [IPAddr.new("::1").to_i], - ["::ffff:192.168.1.2/120", Socket::AF_INET], - ["[192.168.1.2]/120"], - ].each { |args| - ->{ - IPAddr.new(*args) - }.should raise_error(ArgumentError) - } - end + it "raises on incorrect IPAddr strings" do + [ + ["::1/255.255.255.0"], + [IPAddr.new("::1").to_i], + ["::ffff:192.168.1.2/120", Socket::AF_INET], + ["[192.168.1.2]/120"], + ].each { |args| + ->{ + IPAddr.new(*args) + }.should.raise(ArgumentError) + } end end diff --git a/spec/ruby/library/ipaddr/operator_spec.rb b/spec/ruby/library/ipaddr/operator_spec.rb index f90c56009c..3337d22300 100644 --- a/spec/ruby/library/ipaddr/operator_spec.rb +++ b/spec/ruby/library/ipaddr/operator_spec.rb @@ -66,17 +66,17 @@ describe "IPAddr Operator" do end it "checks whether an address is included in a range" do - @a.should include(IPAddr.new("3ffe:505:2::")) - @a.should include(IPAddr.new("3ffe:505:2::1")) - @a.should_not include(IPAddr.new("3ffe:505:3::")) + @a.should.include?(IPAddr.new("3ffe:505:2::")) + @a.should.include?(IPAddr.new("3ffe:505:2::1")) + @a.should_not.include?(IPAddr.new("3ffe:505:3::")) net1 = IPAddr.new("192.168.2.0/24") - net1.should include(IPAddr.new("192.168.2.0")) - net1.should include(IPAddr.new("192.168.2.255")) - net1.should_not include(IPAddr.new("192.168.3.0")) + net1.should.include?(IPAddr.new("192.168.2.0")) + net1.should.include?(IPAddr.new("192.168.2.255")) + net1.should_not.include?(IPAddr.new("192.168.3.0")) # test with integer parameter int = (192 << 24) + (168 << 16) + (2 << 8) + 13 - net1.should include(int) - net1.should_not include(int+255) + net1.should.include?(int) + net1.should_not.include?(int+255) end end diff --git a/spec/ruby/library/ipaddr/reverse_spec.rb b/spec/ruby/library/ipaddr/reverse_spec.rb index 6ebb343269..9bda60ca70 100644 --- a/spec/ruby/library/ipaddr/reverse_spec.rb +++ b/spec/ruby/library/ipaddr/reverse_spec.rb @@ -13,7 +13,7 @@ describe "IPAddr#ip6_arpa" do IPAddr.new("3ffe:505:2::f").ip6_arpa.should == "f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.5.0.5.0.e.f.f.3.ip6.arpa" ->{ IPAddr.new("192.168.2.1").ip6_arpa - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -22,6 +22,6 @@ describe "IPAddr#ip6_int" do IPAddr.new("3ffe:505:2::f").ip6_int.should == "f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.5.0.5.0.e.f.f.3.ip6.int" ->{ IPAddr.new("192.168.2.1").ip6_int - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end |
