Sha256: 957c9836aab6eadfcb413e29414f2a0870e3525198fc7227c3cdde0a8a37be5d
Contents?: true
Size: 519 Bytes
Versions: 16
Compression:
Stored size: 519 Bytes
Contents
class DefineMethodByProcScope in_scope = true method_proc = proc { in_scope } define_singleton_method(:proc_test, &method_proc) end describe "Kernel#define_singleton_method" do it "defines a new singleton method for objects" do s = Object.new s.define_singleton_method(:test) { "world!" } s.test.should == "world!" lambda { Object.new.test }.should raise_error(NoMethodError) end it "maintains the Proc's scope" do DefineMethodByProcScope.proc_test.should == true end end
Version data entries
16 entries across 16 versions & 1 rubygems