Created
November 2, 2010 23:07
Revisions
-
joonyou created this gist
Nov 2, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ require 'rspec' class Victim def called_name caller_name = caller[0].scan(/\`.*\'/).first.gsub(/\`|\'/,"") rescue "outside of self" if caller_name =="my_caller" "looks like it's called from my_caller" else "who's calling me? #{caller_name} is" end end def my_caller called_name end end describe "called from another method" do it "should return my_caller" do Victim.new.my_caller.should eql("looks like it's called from my_caller") end it "should return name of method" do Victim.new.called_name.should eql("who's calling me? outside of self is") end end