summaryrefslogtreecommitdiff
path: root/spec/ruby/library/ipaddr/new_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/ipaddr/new_spec.rb')
-rw-r--r--spec/ruby/library/ipaddr/new_spec.rb47
1 files changed, 35 insertions, 12 deletions
diff --git a/spec/ruby/library/ipaddr/new_spec.rb b/spec/ruby/library/ipaddr/new_spec.rb
index 3148d6e39c..714c1e2f1a 100644
--- a/spec/ruby/library/ipaddr/new_spec.rb
+++ b/spec/ruby/library/ipaddr/new_spec.rb
@@ -77,17 +77,40 @@ describe "IPAddr#new" do
a.family.should == Socket::AF_INET6
end
- 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)
- }
+ ipaddr_version = if defined?(IPAddr::VERSION) #ruby_version_is ""..."3.1" do
+ IPAddr::VERSION
+ else
+ "1.2.2"
+ end
+
+ version_is ipaddr_version, ""..."1.2.3" do #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
+
+ version_is ipaddr_version, "1.2.3" do #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
end
end