summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2020-12-19 03:16:20 +0900
committerYusuke Endoh <mame@ruby-lang.org>2020-12-19 03:16:20 +0900
commit346bf0f5a586ce6140e28aca145e5b6a8160ee4f (patch)
treec47b7b698ddbe0f6d5f4f18790b330422eba7bc1 /spec
parent5944c4b3cfbbf8b774a4a76ca71ab9f71c71d1b0 (diff)
spec/ruby/core/module/attr_*: Add version guards
Diffstat (limited to 'spec')
-rw-r--r--spec/ruby/core/module/attr_accessor_spec.rb16
-rw-r--r--spec/ruby/core/module/attr_reader_spec.rb16
-rw-r--r--spec/ruby/core/module/attr_spec.rb22
-rw-r--r--spec/ruby/core/module/attr_writer_spec.rb16
4 files changed, 56 insertions, 14 deletions
diff --git a/spec/ruby/core/module/attr_accessor_spec.rb b/spec/ruby/core/module/attr_accessor_spec.rb
index c4133d8e4e..665a9346bd 100644
--- a/spec/ruby/core/module/attr_accessor_spec.rb
+++ b/spec/ruby/core/module/attr_accessor_spec.rb
@@ -67,9 +67,19 @@ describe "Module#attr_accessor" do
Module.should have_public_instance_method(:attr_accessor, false)
end
- it "returns an array of defined methods names as symbols" do
- Class.new do
- (attr_accessor :foo, 'bar').should == [:foo, :foo=, :bar, :bar=]
+ ruby_version_is ""..."3.0" do
+ it "returns nil" do
+ Class.new do
+ (attr_accessor :foo, 'bar').should == nil
+ end
+ end
+ end
+
+ ruby_version_is "3.0" do
+ it "returns an array of defined methods names as symbols" do
+ Class.new do
+ (attr_accessor :foo, 'bar').should == [:foo, :foo=, :bar, :bar=]
+ end
end
end
diff --git a/spec/ruby/core/module/attr_reader_spec.rb b/spec/ruby/core/module/attr_reader_spec.rb
index 0693909123..e16b7ba2e3 100644
--- a/spec/ruby/core/module/attr_reader_spec.rb
+++ b/spec/ruby/core/module/attr_reader_spec.rb
@@ -62,9 +62,19 @@ describe "Module#attr_reader" do
Module.should have_public_instance_method(:attr_reader, false)
end
- it "returns an array of defined methods names as symbols" do
- Class.new do
- (attr_reader :foo, 'bar').should == [:foo, :bar]
+ ruby_version_is ""..."3.0" do
+ it "returns nil" do
+ Class.new do
+ (attr_reader :foo, 'bar').should == nil
+ end
+ end
+ end
+
+ ruby_version_is "3.0" do
+ it "returns an array of defined methods names as symbols" do
+ Class.new do
+ (attr_reader :foo, 'bar').should == [:foo, :bar]
+ end
end
end
end
diff --git a/spec/ruby/core/module/attr_spec.rb b/spec/ruby/core/module/attr_spec.rb
index 8c7d27e1e3..060d072f27 100644
--- a/spec/ruby/core/module/attr_spec.rb
+++ b/spec/ruby/core/module/attr_spec.rb
@@ -146,11 +146,23 @@ describe "Module#attr" do
Module.should have_public_instance_method(:attr, false)
end
- it "returns an array of defined methods names as symbols" do
- Class.new do
- (attr :foo, 'bar').should == [:foo, :bar]
- (attr :baz, false).should == [:baz]
- (attr :qux, true).should == [:qux, :qux=]
+ ruby_version_is ""..."3.0" do
+ it "returns nil" do
+ Class.new do
+ (attr :foo, 'bar').should == nil
+ (attr :baz, false).should == nil
+ (attr :qux, true).should == nil
+ end
+ end
+ end
+
+ ruby_version_is "3.0" do
+ it "returns an array of defined methods names as symbols" do
+ Class.new do
+ (attr :foo, 'bar').should == [:foo, :bar]
+ (attr :baz, false).should == [:baz]
+ (attr :qux, true).should == [:qux, :qux=]
+ end
end
end
end
diff --git a/spec/ruby/core/module/attr_writer_spec.rb b/spec/ruby/core/module/attr_writer_spec.rb
index c5a00b8233..59d8b7bf53 100644
--- a/spec/ruby/core/module/attr_writer_spec.rb
+++ b/spec/ruby/core/module/attr_writer_spec.rb
@@ -62,9 +62,19 @@ describe "Module#attr_writer" do
Module.should have_public_instance_method(:attr_writer, false)
end
- it "returns an array of defined methods names as symbols" do
- Class.new do
- (attr_writer :foo, 'bar').should == [:foo=, :bar=]
+ ruby_version_is ""..."3.0" do
+ it "returns nil" do
+ Class.new do
+ (attr_writer :foo, 'bar').should == nil
+ end
+ end
+ end
+
+ ruby_version_is "3.0" do
+ it "returns an array of defined methods names as symbols" do
+ Class.new do
+ (attr_writer :foo, 'bar').should == [:foo=, :bar=]
+ end
end
end
end