Sha256: cfca6845c1b994320fa4f96065ebbc0d70140d7649c5c2a7af6e5353d38f778b

Contents?: true

Size: 1.04 KB

Versions: 11

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

require 'spec_helper'

describe Mongo::Operation::KillCursors::Legacy do

  let(:spec) do
    { coll_name: TEST_COLL,
      db_name: SpecConfig.instance.test_db,
      :cursor_ids => [1,2]
    }
  end
  let(:op) { described_class.new(spec) }

  describe '#initialize' do

    it 'sets the spec' do
      expect(op.spec).to be(spec)
    end
  end

  describe '#==' do

    context ' when two ops have different specs' do
      let(:other_spec) do
        { :cursor_ids => [1, 2, 3] }
      end
      let(:other) { described_class.new(other_spec) }

      it 'returns false' do
        expect(op).not_to eq(other)
      end
    end
  end

  describe '#message' do
    let(:expected_cursor_ids) do
      spec[:cursor_ids].map { |v| BSON::Int64.new(v) }
    end

    it 'creates a kill cursors wire protocol message with correct specs' do
      expect(Mongo::Protocol::KillCursors).to receive(:new).with(TEST_COLL, SpecConfig.instance.test_db, expected_cursor_ids)
      op.send(:message, double('server'))
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mongo-2.16.4 spec/mongo/operation/kill_cursors_spec.rb
mongo-2.17.4 spec/mongo/operation/kill_cursors_spec.rb
mongo-2.17.3 spec/mongo/operation/kill_cursors_spec.rb
mongo-2.17.2 spec/mongo/operation/kill_cursors_spec.rb
mongo-2.16.3 spec/mongo/operation/kill_cursors_spec.rb
mongo-2.16.2 spec/mongo/operation/kill_cursors_spec.rb
mongo-2.17.1 spec/mongo/operation/kill_cursors_spec.rb
mongo-2.16.1 spec/mongo/operation/kill_cursors_spec.rb
mongo-2.17.0 spec/mongo/operation/kill_cursors_spec.rb
mongo-2.16.0 spec/mongo/operation/kill_cursors_spec.rb
mongo-2.16.0.alpha1 spec/mongo/operation/kill_cursors_spec.rb