Sha256: cd22e29ccb4ceb06832bf1f5a6fb581ed98d30d1245ef32e9b9dcc2467e7ad52
Contents?: true
Size: 1.25 KB
Versions: 3
Compression:
Stored size: 1.25 KB
Contents
class DefSpecSingleton class << self def a_class_method;self;end end end describe "A method definition inside a metaclass scope" do it "can create a class method" do DefSpecSingleton.a_class_method.should == DefSpecSingleton lambda { Object.a_class_method }.should raise_error(NoMethodError) end it "can create a singleton method" do obj = Object.new class << obj def a_singleton_method;self;end end obj.a_singleton_method.should == obj lambda { Object.new.a_singleton_method }.should raise_error(NoMethodError) end end describe "A method definition inside an instance_eval" do it "creates a singleton method" do obj = Object.new obj.instance_eval do def an_instance_eval_method;self;end end obj.an_instance_eval_method.should == obj other = Object.new lambda { other.an_instance_eval_method }.should raise_error(NoMethodError) end it "creates a singleton method when evaluated inside a metaclass" do obj = Object.new obj.instance_eval do class << self def a_metaclass_eval_method;self;end end end obj.a_metaclass_eval_method.should == obj other = Object.new lambda { other.a_metaclass_eval_method }.should raise_error(NoMethodError) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
opal-0.3.41 | spec/language/def_spec.rb |
opal-0.3.40 | spec/language/def_spec.rb |
opal-0.3.39 | spec/language/def_spec.rb |