Sha256: 824ce9c4ef88e509cb5a740560127951fe803116d3be70810ec896bd9f5a4c9d

Contents?: true

Size: 1.15 KB

Versions: 9

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true
# rubocop:todo all

require 'spec_helper'

describe Mongo::Operation::Limited do

  describe '#options' do

    let(:limited) do
      Class.new do
        include Mongo::Operation::Specifiable
        include Mongo::Operation::Limited
      end.new({ :options => spec })
    end

    let(:server) { double('server') }

    context 'when no limit is provided' do

      let(:spec) do
        { :skip => 5 }
      end

      it 'returns a limit of -1' do
        expect(limited.send(:options, server)).to eq({ :skip => 5, :limit => -1 })
      end
    end

    context 'when a limit is already provided' do

      context 'when the limit is -1' do

        let(:spec) do
          { :skip => 5, :limit => -1 }
        end

        it 'returns a limit of -1' do
          expect(limited.send(:options, server)).to eq({ :skip => 5, :limit => -1 })
        end
      end

      context 'when the limit is not -1' do

        let(:spec) do
          { :skip => 5, :limit => 5 }
        end

        it 'returns a limit of -1' do
          expect(limited.send(:options, server)).to eq({ :skip => 5, :limit => -1 })
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
mongo-2.21.0 spec/mongo/operation/limited_spec.rb
mongo-2.20.1 spec/mongo/operation/limited_spec.rb
mogno-2.20.0 spec/mongo/operation/limited_spec.rb
mogno-1.0.0 spec/mongo/operation/limited_spec.rb
mongo-2.20.0 spec/mongo/operation/limited_spec.rb
mongo-2.19.3 spec/mongo/operation/limited_spec.rb
mongo-2.19.2 spec/mongo/operation/limited_spec.rb
mongo-2.19.1 spec/mongo/operation/limited_spec.rb
mongo-2.19.0 spec/mongo/operation/limited_spec.rb