Sha256: dea7a982ff3f5cd5005c93d122e068b2eeebb75b6499cfb5000acea325de6e2b

Contents?: true

Size: 1.67 KB

Versions: 12

Compression:

Stored size: 1.67 KB

Contents

require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

module ModuleSpecs
  class NoInheritance
    def method_to_undef() 1 end
    def another_method_to_undef() 1 end
  end

  class Parent
    def method_to_undef() 1 end
    def another_method_to_undef() 1 end
  end

  class Child < Parent
  end

  class Ancestor
    def method_to_undef() 1 end
    def another_method_to_undef() 1 end
  end

  class Descendant < Ancestor
  end
end

describe "Module#undef_method with symbol" do
  it "removes a method defined in a class" do
    x = ModuleSpecs::NoInheritance.new

    x.method_to_undef.should == 1

    ModuleSpecs::NoInheritance.send :undef_method, :method_to_undef

    lambda { x.method_to_undef }.should raise_error(NoMethodError)
  end

  it "removes a method defined in a super class" do
    child = ModuleSpecs::Child.new
    child.method_to_undef.should == 1

    ModuleSpecs::Child.send :undef_method, :method_to_undef

    lambda { child.method_to_undef }.should raise_error(NoMethodError)
  end
end

describe "Module#undef_method with string" do
  it "removes a method defined in a class" do
    x = ModuleSpecs::NoInheritance.new

    x.another_method_to_undef.should == 1

    ModuleSpecs::NoInheritance.send :undef_method, 'another_method_to_undef'

    lambda { x.another_method_to_undef }.should raise_error(NoMethodError)
  end

  it "removes a method defined in a super class" do
    child = ModuleSpecs::Child.new
    child.another_method_to_undef.should == 1

    ModuleSpecs::Child.send :undef_method, 'another_method_to_undef'

    lambda { child.another_method_to_undef }.should raise_error(NoMethodError)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
opal-0.4.4 spec/rubyspec/core/module/undef_method_spec.rb
opal-0.4.3 spec/rubyspec/core/module/undef_method_spec.rb
opal-0.4.2 spec/rubyspec/core/module/undef_method_spec.rb
opal-0.4.1 spec/rubyspec/core/module/undef_method_spec.rb
opal-0.4.0 spec/rubyspec/core/module/undef_method_spec.rb
opal-0.3.44 spec/rubyspec/core/module/undef_method_spec.rb
opal-0.3.43 spec/rubyspec/core/module/undef_method_spec.rb
opal-0.3.42 spec/core/module/undef_method_spec.rb
opal-0.3.41 spec/core/module/undef_method_spec.rb
opal-0.3.40 spec/core/module/undef_method_spec.rb
opal-0.3.39 spec/core/module/undef_method_spec.rb
opal-0.3.38 spec/core/module/undef_method_spec.rb