Sha256: d5df448b1a9070d06272740615a7ac53cd92e983cc97f1640c658fa1abce07e6
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
require 'spec_helper' describe "MongoDoc::Contexts::Ids" do class Address include MongoDoc::Document include MongoDoc::Matchers attr_accessor :number attr_accessor :street end let(:criteria) { Mongoid::Criteria.new(Address) } let(:context) { criteria.context } context "#id_criteria" do context "single id" do let(:id) { 'a' * 24 } let(:obj_id) { Mongo::ObjectID.from_string(id) } it "converts strings to an object id" do criteria.should_receive(:id).with(obj_id) context.stub(:one) context.id_criteria(id) end it "delegates to one if passed a string or ObjectID" do context.should_receive(:one) context.id_criteria(id) end end context "mutliple ids" do let(:ids) { ['a' * 24, 'b' * 24] } let(:obj_ids) { [Mongo::ObjectID.from_string(ids.first), Mongo::ObjectID.from_string(ids.last)] } it "converts strings to an object id" do criteria.should_receive(:id).with(obj_ids) criteria.stub(:entries) context.id_criteria(ids) end it "delegates to entries if passed an array" do criteria.should_receive(:entries) context.id_criteria(ids) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mongo_doc-0.4.2 | spec/contexts/ids_spec.rb |
mongo_doc-0.4.1 | spec/contexts/ids_spec.rb |
mongo_doc-0.4.0 | spec/contexts/ids_spec.rb |