Sha256: b717e8a577ff2e0867c8d61a16055b9ffe39853828e03e10f206ea3b0eceb3cf

Contents?: true

Size: 988 Bytes

Versions: 10

Compression:

Stored size: 988 Bytes

Contents

# frozen_string_literal: true

require "spec_helper"

describe Mongoid::Matchable::Eq do

  let(:matcher) do
    described_class.new("first")
  end

  describe "#_matches?" do

    context "when the values are equal" do

      it "returns true" do
        expect(matcher._matches?("$eq" => "first")).to be true
      end
    end

    context "when the values are not equal" do

      it "returns false" do
        expect(matcher._matches?("$eq" => "second")).to be false
      end
    end

    context "when the value is an array" do

      let(:array_matcher) do
        described_class.new([ "first" ])
      end

      context "when the value is in the array" do

        it "returns true" do
          expect(array_matcher._matches?("$eq" => "first")).to be true
        end
      end

      context "when the value is not in the array" do

        it "returns false" do
          expect(array_matcher._matches?("$eq" => "second")).to be false
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mongoid-7.0.13 spec/mongoid/matchable/eq_spec.rb
mongoid-7.0.12 spec/mongoid/matchable/eq_spec.rb
mongoid-7.0.11 spec/mongoid/matchable/eq_spec.rb
mongoid-7.0.10 spec/mongoid/matchable/eq_spec.rb
mongoid-7.0.8 spec/mongoid/matchable/eq_spec.rb
mongoid-7.0.7 spec/mongoid/matchable/eq_spec.rb
mongoid-7.0.6 spec/mongoid/matchable/eq_spec.rb
mongoid-7.0.5 spec/mongoid/matchable/eq_spec.rb
mongoid-7.0.4 spec/mongoid/matchable/eq_spec.rb
mongoid-7.0.3 spec/mongoid/matchable/eq_spec.rb