spec/mongo/protocol/query_spec.rb in mongo-2.11.6 vs spec/mongo/protocol/query_spec.rb in mongo-2.12.0.rc0
- old
+ new
@@ -1,19 +1,19 @@
-# encoding: UTF-8
-require 'spec_helper'
+require 'lite_spec_helper'
+require 'support/shared/protocol'
describe Mongo::Protocol::Query do
let(:opcode) { 2004 }
let(:db) { SpecConfig.instance.test_db }
- let(:coll) { TEST_COLL }
- let(:ns) { "#{db}.#{coll}" }
+ let(:collection_name) { 'protocol-test' }
+ let(:ns) { "#{db}.#{collection_name}" }
let(:selector) { { :name => 'Tyler' } }
let(:options) { Hash.new }
let(:message) do
- described_class.new(db, coll, selector, options)
+ described_class.new(db, collection_name, selector, options)
end
describe '#initialize' do
it 'sets the namespace' do
@@ -64,21 +64,21 @@
context 'when the other is a query' do
context 'when the fields are equal' do
let(:other) do
- described_class.new(db, coll, selector, options)
+ described_class.new(db, collection_name, selector, options)
end
it 'returns true' do
expect(message).to eq(other)
end
end
context 'when the database is not equal' do
let(:other) do
- described_class.new('tyler', coll, selector, options)
+ described_class.new('tyler', collection_name, selector, options)
end
it 'returns false' do
expect(message).not_to eq(other)
end
@@ -94,21 +94,21 @@
end
end
context 'when the selector is not equal' do
let(:other) do
- described_class.new(db, coll, { :a => 1 }, options)
+ described_class.new(db, collection_name, { :a => 1 }, options)
end
it 'returns false' do
expect(message).not_to eq(other)
end
end
context 'when the options are not equal' do
let(:other) do
- described_class.new(db, coll, selector, :skip => 2)
+ described_class.new(db, collection_name, selector, :skip => 2)
end
it 'returns false' do
expect(message).not_to eq(other)
end
@@ -223,11 +223,11 @@
end
context 'when the namespace contains unicode characters' do
let(:field) { bytes.to_s[20..40] }
- let(:coll) do
+ let(:collection_name) do
'områder'
end
it 'serializes the namespace' do
expect(field).to be_cstring(ns)
@@ -318,11 +318,11 @@
let(:selector) do
{ ping: 1 }
end
it 'returns a compressed message' do
- expect(message.compress!('zlib')).to be_a(Mongo::Protocol::Compressed)
+ expect(message.maybe_compress('zlib')).to be_a(Mongo::Protocol::Compressed)
end
end
context 'when the selector represents a command for which compression is not allowed' do
@@ -333,10 +333,10 @@
end
context "when the command is #{command}" do
it 'does not allow compression for the command' do
- expect(message.compress!('zlib')).to be(message)
+ expect(message.maybe_compress('zlib')).to be(message)
end
end
end
end
end