Sha256: d4e0d3568cd53a4d63937e6f60959da5e193bf6b9d183536b06de5e469a57cec

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 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 = double('Return Value')
    aliasable.should_receive(:test).and_return(retval)
    aliasable.other.should be(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 eql(File.expand_path('../../../../../lib/axiom/support/aliasable.rb', __FILE__))
    line.to_i.should be(38)
  end

  it 'sets the file and line number properly' do
    if RUBY_PLATFORM.include?('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
axiom-0.1.1 spec/unit/axiom/aliasable/inheritable_alias_spec.rb