Sha256: fa55caa5f0324db344d1f27b466c30f1e3090d1bc63c612bd90d286a2bf34028
Contents?: true
Size: 518 Bytes
Versions: 60
Compression:
Stored size: 518 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
60 entries across 60 versions & 3 rubygems