Sha256: 41408dc0030c894bd718b95ad2796b3058f1d33cbb8b5dd63d3c8964b55e817d

Contents?: true

Size: 763 Bytes

Versions: 3

Compression:

Stored size: 763 Bytes

Contents

require "spec_helper"

describe MongoDoc::Contexts do

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

    context "when criteria is for a top-level MongoDoc::Document" do
      let(:klass) { stub('klass', :collection => stub('collection')) }

      it "creates a MongoDoc context" do
        MongoDoc::Contexts::Mongo.should_receive(:new).with(criteria)
        Mongoid::Contexts.context_for(criteria)
      end
    end

    context "when criteria is for an embedded MongoDoc::Document" do
      let(:klass) { stub('klass') }

      it "creates an Enumerable context" do
        MongoDoc::Contexts::Enumerable.should_receive(:new).with(criteria)
        Mongoid::Contexts.context_for(criteria)
      end
    end
  end

end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
mongo_doc-0.3.1 spec/contexts_spec.rb
mongo_doc-0.3.0 spec/contexts_spec.rb
mongodoc-0.2.4 spec/contexts_spec.rb