Sha256: bdf8315122b7b894639df0204306896d532bf4d8293d82d3a898084a1940866c

Contents?: true

Size: 941 Bytes

Versions: 29

Compression:

Stored size: 941 Bytes

Contents

require 'spec_helper'

describe "MongoDoc::Root" do
  class RootTest
    include MongoDoc::Root
    attr_accessor_with_default(:_associations) {[]}
    attr_accessor :association
  end

  let(:doc) { RootTest.new }

  context "cascade properties" do
    let(:prop_val) { stub }

    %w(_modifier_path _root _selector_path).each do |prop|
      it "sets the #{prop}" do
        doc.send("#{prop}=", prop_val)
        doc.send(prop).should == prop_val
      end

      it "sets the prop on any associations" do
        doc.association = stub
        doc.association.should_receive("#{prop}=").with(prop_val)
        doc._associations = ['association']
        doc.send("#{prop}=", prop_val)
      end
    end
  end

  describe "#_selector_path" do
    it "defaults to ''" do
      doc._selector_path.should == ''
    end
  end

  describe "#_modifier_path" do
    it "defaults to ''" do
      doc._modifier_path.should == ''
    end
  end
end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
mongo_doc-0.6.26 spec/root_spec.rb
mongo_doc-0.6.25 spec/root_spec.rb
mongo_doc-0.6.23 spec/root_spec.rb
mongo_doc-0.6.22 spec/root_spec.rb
mongo_doc-0.6.21 spec/root_spec.rb
mongo_doc-0.6.20 spec/root_spec.rb
mongo_doc-0.6.19 spec/root_spec.rb
mongo_doc-0.6.18 spec/root_spec.rb
mongo_doc-0.6.17 spec/root_spec.rb
mongo_doc-0.6.16 spec/root_spec.rb
mongo_doc-0.6.15 spec/root_spec.rb
mongo_doc-0.6.14 spec/root_spec.rb
mongo_doc-0.6.13 spec/root_spec.rb
mongo_doc-0.6.12 spec/root_spec.rb
mongo_doc-0.6.11 spec/root_spec.rb
mongo_doc-0.6.10 spec/root_spec.rb
mongo_doc-0.6.9 spec/root_spec.rb
mongo_doc-0.6.8 spec/root_spec.rb
mongo_doc-0.6.7 spec/root_spec.rb
mongo_doc-0.6.6 spec/root_spec.rb