spec/mongo/query_cache_spec.rb in mongo-2.16.4 vs spec/mongo/query_cache_spec.rb in mongo-2.17.0

- old
+ new

@@ -189,86 +189,19 @@ it 'returns the caching cursor' do expect(Mongo::QueryCache.get(**query_options)).to eq(caching_cursor) end end - context 'when the query has a limit but negative' do - let(:limit) { -5 } - - it 'returns the caching cursor' do - expect(Mongo::QueryCache.get(**query_options)).to eq(caching_cursor) - end - end - context 'when the query has no limit' do let(:limit) { nil } it 'returns the caching cursor' do expect(Mongo::QueryCache.get(**query_options)).to eq(caching_cursor) end end - - context 'when the query has a 0 limit' do - let(:limit) { 0 } - - it 'returns the caching cursor' do - expect(Mongo::QueryCache.get(**query_options)).to eq(caching_cursor) - end - end end - context 'when that entry has a 0 limit' do - let(:caching_cursor_options) do - { - namespace: 'db.coll', - selector: { field: 'value' }, - limit: 0, - } - end - - let(:query_options) do - caching_cursor_options.merge(limit: limit) - end - - before do - allow(view).to receive(:limit) { 0 } - end - - context 'when the query has a limit' do - let(:limit) { 5 } - - it 'returns the caching cursor' do - expect(Mongo::QueryCache.get(**query_options)).to eq(caching_cursor) - end - end - - context 'when the query has a limit but negative' do - let(:limit) { -5 } - - it 'returns the caching cursor' do - expect(Mongo::QueryCache.get(**query_options)).to eq(caching_cursor) - end - end - - - context 'when the query has no limit' do - let(:limit) { nil } - - it 'returns the caching cursor' do - expect(Mongo::QueryCache.get(**query_options)).to eq(caching_cursor) - end - end - - context 'when the query has a 0 limit' do - let(:limit) { 0 } - - it 'returns the caching cursor' do - expect(Mongo::QueryCache.get(**query_options)).to eq(caching_cursor) - end - end - end - context 'when that entry has a limit' do let(:caching_cursor_options) do { namespace: 'db.coll', selector: { field: 'value' }, @@ -290,125 +223,27 @@ it 'returns the caching cursor' do expect(Mongo::QueryCache.get(**query_options)).to eq(caching_cursor) end end - context 'and the new query has a smaller limit but negative' do - let(:limit) { -4 } - - it 'returns the caching cursor' do - expect(Mongo::QueryCache.get(**query_options)).to eq(caching_cursor) - end - end - context 'and the new query has a larger limit' do let(:limit) { 6 } it 'returns nil' do expect(Mongo::QueryCache.get(**query_options)).to be_nil end end - context 'and the new query has a larger limit but negative' do - let(:limit) { -6 } - - it 'returns nil' do - expect(Mongo::QueryCache.get(**query_options)).to be_nil - end - end - context 'and the new query has the same limit' do let(:limit) { 5 } it 'returns the caching cursor' do expect(Mongo::QueryCache.get(**query_options)).to eq(caching_cursor) end end - context 'and the new query has the same limit but negative' do - let(:limit) { -5 } - - it 'returns the caching cursor' do - expect(Mongo::QueryCache.get(**query_options)).to eq(caching_cursor) - end - end - context 'and the new query has no limit' do let(:limit) { nil } - - it 'returns nil' do - expect(Mongo::QueryCache.get(**query_options)).to be_nil - end - end - - context 'and the new query has a 0 limit' do - let(:limit) { 0 } - - it 'returns nil' do - expect(Mongo::QueryCache.get(**query_options)).to be_nil - end - end - end - - context 'when that entry has a negative limit' do - let(:caching_cursor_options) do - { - namespace: 'db.coll', - selector: { field: 'value' }, - limit: -5, - } - end - - let(:query_options) do - caching_cursor_options.merge(limit: limit) - end - - before do - allow(view).to receive(:limit) { -5 } - end - - context 'and the new query has a smaller limit' do - let(:limit) { 4 } - - it 'returns the caching cursor' do - expect(Mongo::QueryCache.get(**query_options)).to eq(caching_cursor) - end - end - - context 'and the new query has a larger limit' do - let(:limit) { 6 } - - it 'returns nil' do - expect(Mongo::QueryCache.get(**query_options)).to be_nil - end - end - - context 'and the new query has the same negative limit' do - let(:limit) { -5 } - - it 'returns the caching cursor' do - expect(Mongo::QueryCache.get(**query_options)).to eq(caching_cursor) - end - end - - context 'and the new query has the same positive limit' do - let(:limit) { 5 } - - it 'returns the caching cursor' do - expect(Mongo::QueryCache.get(**query_options)).to eq(caching_cursor) - end - end - - context 'and the new query has no limit' do - let(:limit) { nil } - - it 'returns nil' do - expect(Mongo::QueryCache.get(**query_options)).to be_nil - end - end - - context 'and the new query has a 0 limit' do - let(:limit) { 0 } it 'returns nil' do expect(Mongo::QueryCache.get(**query_options)).to be_nil end end