1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
# 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
|