Sha256: 3ac646aaf11dcad76c3c4fc4bd5112a7c46b4bd64d9f2deae782d3cde93565bb

Contents?: true

Size: 1 KB

Versions: 16

Compression:

Stored size: 1 KB

Contents

require 'spec_helper'

module ModuleNameSpec
  module A
    class B
    end
  end

  Subclass = Class.new(Hash)
end

describe "Module#name" do
  it "should return the class name for boot types" do
    BasicObject.name.should == "BasicObject"
    Object.name.should == "Object"
    Class.name.should == "Class"
    Module.name.should == "Module"
  end

  it "should return class name for bridged classes" do
    Array.name.should == "Array"
  end

  it "should return name for modules and classes" do
    Enumerator.name.should == "Enumerator"
    Enumerable.name.should == "Enumerable"
  end

  it "should return nil for anonymous class" do
    Class.new.name.should == nil
  end

  it "should join nested classes using '::'" do
    ModuleNameSpec::A.name.should == "ModuleNameSpec::A"
    ModuleNameSpec::A::B.name.should == "ModuleNameSpec::A::B"
  end

  it 'returns correct constant name when created using Const = Class.new(Superclass)' do
    ModuleNameSpec::Subclass.name.should == "ModuleNameSpec::Subclass"
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
opal-0.10.6 spec/opal/core/module/name_spec.rb
opal-0.10.6.beta spec/opal/core/module/name_spec.rb
opal-0.10.5 spec/opal/core/module/name_spec.rb
opal-0.10.4 spec/opal/core/module/name_spec.rb
opal-0.11.0.rc1 spec/opal/core/module/name_spec.rb
opal-0.10.3 spec/opal/core/module/name_spec.rb
opal-0.10.2 spec/opal/core/module/name_spec.rb
opal-0.10.1 spec/opal/core/module/name_spec.rb
opal-0.10.0 spec/opal/core/module/name_spec.rb
opal-0.10.0.rc2 spec/opal/core/module/name_spec.rb
opal-0.10.0.rc1 spec/opal/core/module/name_spec.rb
opal-0.10.0.beta5 spec/opal/core/module/name_spec.rb
opal-0.10.0.beta4 spec/opal/core/module/name_spec.rb
opal-0.10.0.beta3 spec/opal/core/module/name_spec.rb
opal-0.10.0.beta2 spec/opal/core/module/name_spec.rb
opal-0.10.0.beta1 spec/opal/core/module/name_spec.rb