Sha256: c44a8873e0f206c06d8e104a9d624ae33f5bab795ead2ed65d2417cf8aa48ee0

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

# encoding: utf-8

require 'spec_helper'
require File.expand_path('../fixtures/classes', __FILE__)

describe Aliasable, '#inheritable_alias' do
  subject { object.inheritable_alias(aliases) }

  let(:aliases)   { { :other => :test }               }
  let(:object)    { Class.new(AliasableSpecs::Object) }
  let(:aliasable) { object.new                        }

  it_should_behave_like 'a command method'

  it 'creates a method #other' do
    expect { subject }.to change { aliasable.respond_to?(:other) }.
      from(false).
      to(true)
  end

  it 'aliases #other to #test' do
    subject
    retval = mock('Return Value')
    aliasable.should_receive(:test).and_return(retval)
    aliasable.other.should equal(retval)
  end

  specification = proc do
    object.class_eval do
      def test
        caller
      end
    end

    subject

    file, line = aliasable.other.first.split(':')[0, 2]

    File.expand_path(file).should == File.expand_path('../../../../../lib/veritas/support/aliasable.rb', __FILE__)
    line.to_i.should == 23
  end

  it 'sets the file and line number properly' do
    if RUBY_PLATFORM[/java/]
      pending('Kernel#caller returns the incorrect line number in JRuby', &specification)
    else
      instance_eval(&specification)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.4 spec/unit/veritas/aliasable/inheritable_alias_spec.rb