summaryrefslogtreecommitdiff
path: root/spec/ruby/core/module/remove_method_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/module/remove_method_spec.rb')
-rw-r--r--spec/ruby/core/module/remove_method_spec.rb38
1 files changed, 30 insertions, 8 deletions
diff --git a/spec/ruby/core/module/remove_method_spec.rb b/spec/ruby/core/module/remove_method_spec.rb
index b6ae02078f..39add01e36 100644
--- a/spec/ruby/core/module/remove_method_spec.rb
+++ b/spec/ruby/core/module/remove_method_spec.rb
@@ -21,7 +21,7 @@ describe "Module#remove_method" do
end
it "is a public method" do
- Module.should have_public_instance_method(:remove_method, false)
+ Module.public_instance_methods(false).should.include?(:remove_method)
end
it "removes the method from a class" do
@@ -43,6 +43,28 @@ describe "Module#remove_method" do
x.method_to_remove.should == 1
end
+ it "updates the method implementation" do
+ m_module = Module.new do
+ def foo
+ 'm'
+ end
+ end
+
+ a_class = Class.new do
+ include m_module
+
+ def foo
+ 'a'
+ end
+ end
+
+ a = a_class.new
+ foo = -> { a.foo }
+ foo.call.should == 'a'
+ a_class.remove_method(:foo)
+ foo.call.should == 'm'
+ end
+
it "removes multiple methods with 1 call" do
klass = Class.new do
def method_to_remove_1; 1; end
@@ -66,14 +88,14 @@ describe "Module#remove_method" do
end
it "returns self" do
- @module.send(:remove_method, :method_to_remove).should equal(@module)
+ @module.send(:remove_method, :method_to_remove).should.equal?(@module)
end
it "raises a NameError when attempting to remove method further up the inheritance tree" do
Class.new(ModuleSpecs::Second) do
-> {
remove_method :method_to_remove
- }.should raise_error(NameError)
+ }.should.raise(NameError)
end
end
@@ -81,7 +103,7 @@ describe "Module#remove_method" do
Class.new(ModuleSpecs::Second) do
-> {
remove_method :blah
- }.should raise_error(NameError)
+ }.should.raise(NameError)
end
end
@@ -91,19 +113,19 @@ describe "Module#remove_method" do
end
it "raises a FrozenError when passed a name" do
- -> { @frozen.send :remove_method, :method_to_remove }.should raise_error(FrozenError)
+ -> { @frozen.send :remove_method, :method_to_remove }.should.raise(FrozenError)
end
it "raises a FrozenError when passed a missing name" do
- -> { @frozen.send :remove_method, :not_exist }.should raise_error(FrozenError)
+ -> { @frozen.send :remove_method, :not_exist }.should.raise(FrozenError)
end
it "raises a TypeError when passed a not name" do
- -> { @frozen.send :remove_method, Object.new }.should raise_error(TypeError)
+ -> { @frozen.send :remove_method, Object.new }.should.raise(TypeError)
end
it "does not raise exceptions when no arguments given" do
- @frozen.send(:remove_method).should equal(@frozen)
+ @frozen.send(:remove_method).should.equal?(@frozen)
end
end
end