Sha256: 6510e6dde4f1f8e3d95cd066919e68fb1288ab7c45bc6d82dc7fb4364699aadc

Contents?: true

Size: 786 Bytes

Versions: 2

Compression:

Stored size: 786 Bytes

Contents

require File.expand_path(
        File.join(File.dirname(__FILE__), '..', 'spec_helper'))

module MyScriptsTest
  module A
    class B
      class C
      end
    end
  end

  describe String do
    context '#to_class' do
      it 'converts string into appropriate Class constant' do
        "Fixnum".to_class.should == Fixnum
        "MyScriptsTest::A::B::C".to_class.should == MyScriptsTest::A::B::C
      end

      it 'returns nil if string is not convertible into class' do
        "Math".to_class.should == nil
        "Math::PI".to_class.should == nil
        "Something".to_class.should == nil
      end

      it 'deals with leading colons' do
        "::MyScriptsTest::A::B::C".to_class.should == MyScriptsTest::A::B::C
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
my_scripts-0.0.7 spec/my_scripts/extensions_spec.rb
my_scripts-0.0.6 spec/my_scripts/extensions_spec.rb