Sha256: 1bdc4ac53b34bb4a41b8b6f6f6258cb47456f1eeae05fb5433a01603285899d2

Contents?: true

Size: 679 Bytes

Versions: 14

Compression:

Stored size: 679 Bytes

Contents

require 'spec_helper'

describe Mongoid::Criterion::Optional do
  class OptionalTest
    include MongoDoc::Document
  end

  let(:criteria) { Mongoid::Criteria.new(OptionalTest) }
  let(:id) { BSON::ObjectID.new }
  let(:string_id) { id.to_s }

  describe "#id" do
    it "converts a string id to bson ids" do
      criteria.id(string_id)
      BSON::ObjectID.should === criteria.selector[:_id]
    end

    it "converts many string ids to bson ids" do
      criteria.id(string_id, string_id)
      criteria.selector[:_id].should have_key('$in')
      criteria.selector[:_id]['$in'].each do |selector_id|
        BSON::ObjectID.should === selector_id
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mongo_doc-0.6.26 spec/criteria/optional_spec.rb
mongo_doc-0.6.25 spec/criteria/optional_spec.rb
mongo_doc-0.6.23 spec/criteria/optional_spec.rb
mongo_doc-0.6.22 spec/criteria/optional_spec.rb
mongo_doc-0.6.21 spec/criteria/optional_spec.rb
mongo_doc-0.6.20 spec/criteria/optional_spec.rb
mongo_doc-0.6.19 spec/criteria/optional_spec.rb
mongo_doc-0.6.18 spec/criteria/optional_spec.rb
mongo_doc-0.6.17 spec/criteria/optional_spec.rb
mongo_doc-0.6.16 spec/criteria/optional_spec.rb
mongo_doc-0.6.15 spec/criteria/optional_spec.rb
mongo_doc-0.6.14 spec/criteria/optional_spec.rb
mongo_doc-0.6.13 spec/criteria/optional_spec.rb
mongo_doc-0.6.12 spec/criteria/optional_spec.rb