Sha256: e28d9fb2bbfbe653c7a3ddff8d3662b7120ac9144008cf3d07c878d731485902

Contents?: true

Size: 1.39 KB

Versions: 10

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

describe Mongo::Operation::KillCursors do
  include_context 'operation'

  let(:spec) { { :cursor_ids => [1,2] } }
  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

  context '#merge' do
    let(:other_op) { described_class.new(spec) }

    it 'is not allowed' do
      expect{ op.merge(other_op) }.to raise_exception
    end
  end

  context '#merge!' do
    let(:other_op) { described_class.new(spec) }

    it 'is not allowed' do
      expect{ op.merge!(other_op) }.to raise_exception
    end
  end

  describe '#execute' do

    context 'message' do

      it 'creates a kill cursors wire protocol message with correct specs' do
        expect(Mongo::Protocol::KillCursors).to receive(:new) do |ids|
          expect(ids).to eq(spec[:cursor_ids])
        end
        op.execute(primary_context)
      end
    end

    context 'connection' do

      it 'dispatches the message on the connection' do
        expect(connection).to receive(:dispatch)
        op.execute(primary_context)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mongo-2.1.0.beta spec/mongo/operation/kill_cursors_spec.rb
mongo-2.0.6 spec/mongo/operation/kill_cursors_spec.rb
mongo-2.0.5 spec/mongo/operation/kill_cursors_spec.rb
mongo-2.0.4 spec/mongo/operation/kill_cursors_spec.rb
mongo-2.0.3 spec/mongo/operation/kill_cursors_spec.rb
mongo-2.0.2 spec/mongo/operation/kill_cursors_spec.rb
mongo-2.0.1 spec/mongo/operation/kill_cursors_spec.rb
mongo-2.0.0 spec/mongo/operation/kill_cursors_spec.rb
mongo-2.0.0.rc spec/mongo/operation/kill_cursors_spec.rb
mongo-2.0.0.beta spec/mongo/operation/kill_cursors_spec.rb