Sha256: 32ce62361f09792dd34b620f1df558ee4a0bf13d53c9fb08079b0a6ec211c416

Contents?: true

Size: 1.32 KB

Versions: 12

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'

describe Mongo::Operation::Commands::Aggregate do
  include_context 'operation'

  let(:selector) do
    { :aggregate => coll_name,
      :pipeline => [],
    }
  end
  let(:spec) do
    { :selector => selector,
      :options => {},
      :db_name => db_name
    }
  end
  let(:op) { described_class.new(spec) }


  describe '#initialize' do

    context 'spec' do

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

  describe '#==' do

    context ' when two ops have different specs' do
      let(:other_selector) do
        { :aggregate => 'another_test_coll',
          :pipeline => [],
        }
      end
      let(:other_spec) do
        { :selector => other_selector,
          :options => options,
          :db_name => db_name,
        }
      end
      let(:other) { described_class.new(other_spec) }

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

  describe '#execute' do

    context 'when the aggregation fails' do

      let(:selector) do
        { :aggregate => coll_name,
          :pipeline => [{ '$invalid' => 'operator' }],
        }
      end

      it 'raises an exception' do
        expect {
          op.execute(authorized_primary.context)
        }.to raise_error(Mongo::Error::OperationFailure)
      end
    end
  end
end

Version data entries

12 entries across 11 versions & 3 rubygems

Version Path
mongo-2.2.7 spec/mongo/operation/commands/aggregate_spec.rb
mongo-2.2.6 spec/mongo/operation/commands/aggregate_spec.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mongo-2.2.5/spec/mongo/operation/commands/aggregate_spec.rb
mongo-2.2.5 spec/mongo/operation/commands/aggregate_spec.rb
mongo-2.2.4 spec/mongo/operation/commands/aggregate_spec.rb
mongo-2.2.3 spec/mongo/operation/commands/aggregate_spec.rb
mongo-2.2.2 spec/mongo/operation/commands/aggregate_spec.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/mongo-2.2.1/spec/mongo/operation/commands/aggregate_spec.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/mongo-2.2.1/spec/mongo/operation/commands/aggregate_spec.rb
mongo-2.2.1 spec/mongo/operation/commands/aggregate_spec.rb
mongo-2.2.0 spec/mongo/operation/commands/aggregate_spec.rb
mongo-2.2.0.rc0 spec/mongo/operation/commands/aggregate_spec.rb