Sha256: 4117ce2cdb5060102e71c1c734365b304c40ffbd0b0a1cb4a7902c069747c7ec
Contents?: true
Size: 1.93 KB
Versions: 5
Compression:
Stored size: 1.93 KB
Contents
require 'spec_helper' module MongoModel specs_for(Document, EmbeddedDocument) do describe "generating attribute methods" do define_class(:TestDocument, described_class) do property :foo, String def foo(a); "from method"; end end subject { TestDocument.new } it "does not overwrite an existing method" do subject.foo(1).should == "from method" end context "on a subclass" do define_class(:SubDocument, :TestDocument) subject { SubDocument.new } it "does not overwrite methods defined on the superclass" do subject.foo(1).should == "from method" end end context "on a class with an included module" do module TestModule def foo(a); "from method"; end end it "does not overwrite methods defined on the included module" do TestDocument.send(:include, TestModule) subject.foo(1).should == "from method" end end context "on a class with an included concern that defines the property" do define_module(:TestConcern) do extend ActiveSupport::Concern included do property :bar, String end def bar(a); "from concern"; end end context "the base class" do it "does not overwrite methods defined within the concern" do TestDocument.send(:include, TestConcern) subject.bar(1).should == "from concern" end end context "subclasses" do define_class(:SubDocument, :TestDocument) subject { SubDocument.new } it "does not overwrite methods defined within the concern" do SubDocument.send(:include, TestConcern) subject.bar(1).should == "from concern" end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems