1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Cherrypick 9f8d3d0 from ruby/spec

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
marcandre 2017-11-29 19:46:46 +00:00
parent 0c03a89ecd
commit 87bcbf9ef5
8 changed files with 72 additions and 16 deletions

View file

@ -69,9 +69,16 @@ describe "Module#alias_method" do
lambda { @class.make_alias mock('x'), :public_one }.should raise_error(TypeError)
end
ruby_version_is ''...'2.5' do
it "is a private method" do
lambda { @class.alias_method :ichi, :public_one }.should raise_error(NoMethodError)
end
end
ruby_version_is '2.5' do
it "is a public method" do
Module.should have_public_instance_method(:alias_method, false)
end
end
it "returns self" do
@class.send(:alias_method, :checking_return_value, :public_one).should equal(@class)

View file

@ -63,8 +63,15 @@ describe "Module#attr_accessor" do
lambda { c.new.foo=1 }.should raise_error(NoMethodError)
end
ruby_version_is ''...'2.5' do
it "is a private method" do
lambda { Class.new.attr_accessor(:foo) }.should raise_error(NoMethodError)
Module.should have_private_instance_method(:attr_accessor, false)
end
end
ruby_version_is '2.5' do
it "is a public method" do
Module.should have_public_instance_method(:attr_accessor, false)
end
end
describe "on immediates" do

View file

@ -58,7 +58,14 @@ describe "Module#attr_reader" do
lambda { c.new.foo }.should raise_error(NoMethodError)
end
ruby_version_is ''...'2.5' do
it "is a private method" do
lambda { Class.new.attr_reader(:foo) }.should raise_error(NoMethodError)
Module.should have_private_instance_method(:attr_reader, false)
end
end
ruby_version_is '2.5' do
it "is a public method" do
Module.should have_public_instance_method(:attr_reader, false)
end
end
end

View file

@ -143,7 +143,14 @@ describe "Module#attr" do
}.should complain(/boolean argument is obsoleted/)
end
ruby_version_is ''...'2.5' do
it "is a private method" do
lambda { Class.new.attr(:foo) }.should raise_error(NoMethodError)
Module.should have_private_instance_method(:attr, false)
end
end
ruby_version_is '2.5' do
it "is a public method" do
Module.should have_public_instance_method(:attr, false)
end
end
end

View file

@ -58,7 +58,14 @@ describe "Module#attr_writer" do
lambda { c.new.foo=1 }.should raise_error(NoMethodError)
end
ruby_version_is ''...'2.5' do
it "is a private method" do
lambda { Class.new.attr_writer(:foo) }.should raise_error(NoMethodError)
Module.should have_private_instance_method(:attr_writer, false)
end
end
ruby_version_is '2.5' do
it "is a public method" do
Module.should have_public_instance_method(:attr_writer, false)
end
end
end

View file

@ -357,9 +357,16 @@ describe "Module#define_method" do
klass.new.string_test.should == "string_test result"
end
it "is private" do
ruby_version_is ''...'2.5' do
it "is a private method" do
Module.should have_private_instance_method(:define_method)
end
end
ruby_version_is '2.5' do
it "is a public method" do
Module.should have_public_instance_method(:define_method)
end
end
it "returns its symbol" do
class DefineMethodSpecClass

View file

@ -20,9 +20,16 @@ describe "Module#remove_method" do
@module = Module.new { def method_to_remove; end }
end
ruby_version_is ''...'2.5' do
it "is a private method" do
Module.should have_private_instance_method(:remove_method, false)
end
end
ruby_version_is '2.5' do
it "is a public method" do
Module.should have_public_instance_method(:remove_method, false)
end
end
it "removes the method from a class" do
klass = Class.new do

View file

@ -18,9 +18,16 @@ describe "Module#undef_method" do
@module = Module.new { def method_to_undef; end }
end
ruby_version_is ''...'2.5' do
it "is a private method" do
Module.should have_private_instance_method(:undef_method, false)
end
end
ruby_version_is '2.5' do
it "is a public method" do
Module.should have_public_instance_method(:undef_method, false)
end
end
it "requires multiple arguments" do
Module.instance_method(:undef_method).arity.should < 0