Sha256: cacadf972f9e3d6ec986ee3e4cf14fc220691acc13aadac16495279edcab7457

Contents?: true

Size: 724 Bytes

Versions: 10

Compression:

Stored size: 724 Bytes

Contents

require "spec_helper"

describe Mongoid::Contexts do

  context ".context_for" do
    let(:klass) { stub('klass', :embedded => false) }
    let(:criteria) { stub('criteria', :klass => klass) }

    context "when criteria is for a top-level Mongoid::Document" do
      it "creates a Mongo context" do
        Mongoid::Contexts::Mongo.expects(:new).with(criteria)
        Mongoid::Contexts.context_for(criteria)
      end
    end

    context "when criteria is for an embedded Mongoid::Document" do
      it "creates a Mongo context" do
        klass.stubs(:embedded).returns(true)
        Mongoid::Contexts::Enumerable.expects(:new).with(criteria)
        Mongoid::Contexts.context_for(criteria)
      end
    end
  end

end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
mongoid-pre-2.0.0.beta1 spec/unit/mongoid/contexts_spec.rb
mongoid-2.0.0.alpha spec/unit/mongoid/contexts_spec.rb
mongoid-1.2.14 spec/unit/mongoid/contexts_spec.rb
mongoid-1.2.13 spec/unit/mongoid/contexts_spec.rb
mongoid-1.2.12 spec/unit/mongoid/contexts_spec.rb
mongoid-1.2.11 spec/unit/mongoid/contexts_spec.rb
mongoid-1.2.10 spec/unit/mongoid/contexts_spec.rb
mongoid-1.2.9 spec/unit/mongoid/contexts_spec.rb
mongoid-1.2.8 spec/unit/mongoid/contexts_spec.rb
mongoid-1.2.7 spec/unit/mongoid/contexts_spec.rb