Sha256: c6b8a49113731a7dcd8a5ebd6cc13ab617d5457cc0983c89deb64cd4ed4d2c96
Contents?: true
Size: 1.08 KB
Versions: 52
Compression:
Stored size: 1.08 KB
Contents
def f send(@method) end alias g f describe :kernel___method__, :shared => true do it "returns the current method, even when aliased" do f.should == :f end it "returns the original name when aliased method" do g.should == :f end it "returns the caller from blocks too" do def h (1..2).map { send(@method) } end h.should == [:h, :h] end it "returns the caller from define_method too" do klass = Class.new {define_method(:f) {__method__}} klass.new.f.should == :f end it "returns the caller from block inside define_method too" do klass = Class.new {define_method(:f) { 1.times{break __method__}}} klass.new.f.should == :f end it "returns the caller from a define_method called from the same class" do class C define_method(:f) { 1.times{break __method__}} def g; f end end C.new.g.should == :f end it "returns method name even from eval" do def h eval @method.to_s end h.should == :h end it "returns nil when not called from a method" do send(@method).should == nil end end
Version data entries
52 entries across 52 versions & 2 rubygems