1 require File.expand_path('../../../spec_helper', __FILE__)
2 require File.expand_path('../fixtures/classes', __FILE__)
4 describe "UnboundMethod#source_location" do
6 @method = MethodSpecs::SourceLocation.instance_method(:location)
9 it "returns an Array" do
10 @method.source_location.should be_an_instance_of(Array)
13 it "sets the first value to the path of the file in which the method was defined" do
14 file = @method.source_location.first
15 file.should be_an_instance_of(String)
16 file.should == File.dirname(__FILE__) + '/fixtures/classes.rb'
19 it "sets the last value to a Fixnum representing the line on which the method was defined" do
20 line = @method.source_location.last
21 line.should be_an_instance_of(Fixnum)
25 it "returns the last place the method was defined" do
26 MethodSpecs::SourceLocation.instance_method(:redefined).source_location.last.should == 13
29 it "returns the location of the original method even if it was aliased" do
30 MethodSpecs::SourceLocation.instance_method(:aka).source_location.last.should == 17