Sha256: 6e2ec6ec3b933b4d1acb613c24f7b204cac31140e376ebbd51d441bb1bea0b1e

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require File.join(File.dirname(__FILE__), 'test_helper.rb')

class Alias::CoreExtensionsTest < Test::Unit::TestCase
  test "any_const_get fetches simple class" do
    Object.any_const_get("Array").should == Array
  end
  
  test "any_const_get fetches nested class" do
    eval "module ::Somemodule; class Someclass; end; end"
    Object.any_const_get("Somemodule::Someclass").should == Somemodule::Someclass
  end
  
  test "any_const_get returns nil for nonexistent class" do
    Object.any_const_get("NonexistentClass").should == nil
  end
  
  test "slice only returns valid keys given" do
    {:a=>1, :b=>2}.slice(:a, :c).should == {:a=>1}
  end
  
  test "slice_off! returns given keys but takes them off existing hash" do
    h = {:a=>1, :b=>2}
    h.slice_off!(:a, :c).should == {:a=>1}
    h.should == {:b=>2}
  end
  
  test "camelize should uppercase non-underscored string" do
    'man'.camelize.should == 'Man'
  end
  
  test "camelize should camelize underscored string" do
    'some_test'.camelize.should == 'SomeTest'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cldwalker-alias-0.1.1 test/core_extensions_test.rb
cldwalker-alias-0.1.2 test/core_extensions_test.rb