Sha256: b2a1a1db7b6debaad97087c28a4b24f8aedab8e0a066c41592695016db9c5ca5

Contents?: true

Size: 908 Bytes

Versions: 43

Compression:

Stored size: 908 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

43 entries across 43 versions & 3 rubygems

Version Path
opal-0.7.0.beta1 spec/opal/core/module/remove_const_spec.rb
opal-0.6.2 spec/opal/core/module/remove_const_spec.rb
opal-0.6.1 spec/opal/core/module/remove_const_spec.rb