Sha256: a88eccadaac59e87181b4bd88bddef253a40e31d7ca24c71375db8849cfffc11

Contents?: true

Size: 1010 Bytes

Versions: 2

Compression:

Stored size: 1010 Bytes

Contents

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

describe "AliasConstantCreator" do
  before { @manager = Manager.new }

  def create_aliases(hash, options={})
    @manager.create_aliases(:constant, hash, options)
  end

  def expect_aliases(hash)
    arr = Creators::ConstantCreator.maps_config(hash)
    Creators::ConstantCreator.expects(:generates_aliases).with(arr).returns('')
  end
  
  it "deletes existing aliases" do
    expect_aliases "Array"=>'Ar'
    create_aliases "Alias::Creators::ConstantCreator"=>"Alias::Creator", "Array"=>"Ar"
  end

  it "deletes existing aliases unless force option" do
    h1 = {"Alias::Creators::ConstantCreator"=>"Alias::Creator", "Array"=>"Ar"}
    expect_aliases h1
    create_aliases h1, :force=>true
  end

  it "deletes invalid classes" do
    eval "module ::Bling; end"
    expect_aliases 'Array'=>'Ar'
    create_aliases "Blah"=>"Bling", "Array"=>"Ar"
  end

  it "creates aliases" do
    create_aliases 'Time'=>'T'
    ::Time.should == ::T
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alias-0.2.3 test/constant_creator_test.rb
alias-0.2.2 test/constant_creator_test.rb