Sha256: 3df1cfad4937564f463050d0b7f84d4c03b290fabeabac2a6a5ba96db7ae79f4

Contents?: true

Size: 817 Bytes

Versions: 6

Compression:

Stored size: 817 Bytes

Contents

# frozen_string_literal: true
# encoding: utf-8

shared_examples_for "returns a cloned query" do

  it "returns a cloned query" do
    expect(selection).to_not equal(query)
  end
end

shared_examples_for 'requires an argument' do
  context "when provided no argument" do

    let(:selection) do
      query.send(query_method)
    end

    it "raises ArgumentError" do
      expect do
        selection.selector
      end.to raise_error(ArgumentError)
    end
  end
end

shared_examples_for 'requires a non-nil argument' do
  context "when provided nil" do

    let(:selection) do
      query.send(query_method, nil)
    end

    it "raises CriteriaArgumentRequired" do
      expect do
        selection.selector
      end.to raise_error(Mongoid::Errors::CriteriaArgumentRequired, /#{query_method}/)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mongoid-7.3.5 spec/mongoid/criteria/queryable/selectable_shared_examples.rb
mongoid-7.3.4 spec/mongoid/criteria/queryable/selectable_shared_examples.rb
mongoid-7.3.3 spec/mongoid/criteria/queryable/selectable_shared_examples.rb
mongoid-7.3.2 spec/mongoid/criteria/queryable/selectable_shared_examples.rb
mongoid-7.3.1 spec/mongoid/criteria/queryable/selectable_shared_examples.rb
mongoid-7.3.0 spec/mongoid/criteria/queryable/selectable_shared_examples.rb