spec/ruby/core/module/attr_*: Add version guards

This commit is contained in:
Yusuke Endoh 2020-12-19 03:16:20 +09:00
Родитель 5944c4b3cf
Коммит 346bf0f5a5
4 изменённых файлов: 56 добавлений и 14 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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