spec/mongo/protocol/query_spec.rb in mongo-2.4.3 vs spec/mongo/protocol/query_spec.rb in mongo-2.5.0.beta

- old
+ new

@@ -294,6 +294,51 @@ expect(field).to be_bson(projection) end end end end + + describe '#registry' do + + context 'when the class is loaded' do + + it 'registers the op code in the Protocol Registry' do + expect(Mongo::Protocol::Registry.get(described_class::OP_CODE)).to be(described_class) + end + + it 'creates an #op_code instance method' do + expect(message.op_code).to eq(described_class::OP_CODE) + end + end + end + + describe '#compress' do + + context 'when the selector represents a command that can be compressed' do + + let(:selector) do + { ping: 1 } + end + + it 'returns a compressed message' do + expect(message.compress!('zlib')).to be_a(Mongo::Protocol::Compressed) + end + end + + context 'when the selector represents a command for which compression is not allowed' do + + Mongo::Monitoring::Event::Secure::REDACTED_COMMANDS.each do |command| + + let(:selector) do + { command => 1 } + end + + context "when the command is #{command}" do + + it 'does not allow compression for the command' do + expect(message.compress!('zlib')).to be(message) + end + end + end + end + end end