Sha256: 4d8947442704723cc8b030a91b8c241ee991df5795b983e78a38b0ae0b2d604e

Contents?: true

Size: 911 Bytes

Versions: 5

Compression:

Stored size: 911 Bytes

Contents

require File.expand_path('../../../fixtures/constants', __FILE__)

describe "Module#remove_const" do
  it "removes the constant specified by a String or Symbol from the receiver's constant table" do
    ConstantSpecs::ModuleM::CS_CONST252 = :const252
    ConstantSpecs::ModuleM::CS_CONST252.should == :const252

    ConstantSpecs::ModuleM.send :remove_const, :CS_CONST252
    lambda { ConstantSpecs::ModuleM::CS_CONST252 }.should raise_error(NameError)

    ConstantSpecs::ModuleM::CS_CONST253 = :const253
    ConstantSpecs::ModuleM::CS_CONST253.should == :const253

    ConstantSpecs::ModuleM.send :remove_const, "CS_CONST253"
    lambda { ConstantSpecs::ModuleM::CS_CONST253 }.should raise_error(NameError)
  end

  it "returns the value of the removed constant" do
    ConstantSpecs::ModuleM::CS_CONST254 = :const254
    ConstantSpecs::ModuleM.send(:remove_const, :CS_CONST254).should == :const254
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opal-0.6.0 spec/opal/core/module/remove_const_spec.rb
opal-0.5.5 spec/opal/core/module/remove_const_spec.rb
opal-0.5.4 spec/corelib/module/remove_const_spec.rb
opal-0.5.2 spec/corelib/module/remove_const_spec.rb
opal-0.5.0 spec/corelib/module/remove_const_spec.rb