Sha256: 3679b54cf70adc5c15eb8dc450aca4116c6c1e4459f845b71886ee10bc8e635a

Contents?: true

Size: 703 Bytes

Versions: 3

Compression:

Stored size: 703 Bytes

Contents

require "spec_helper"

describe Mongoid::Matchers::All do

  let(:matcher) do
    described_class.new(["first", "second", "third"])
  end

  describe "#matches?" do

    context "when the attribute includes all of the values" do

      it "returns true" do
        matcher.matches?("$all" => ["first", /\Asec.*\z/]).should be_true
      end
    end

    context "when the attributes doesn't include all of the values" do

      it "returns false" do
        matcher.matches?("$all" => ["second", "third", "fourth"]).should be_false
      end
    end

    context "when the value is empty" do
      it "returns false" do
        matcher.matches?("$all" => []).should be_false
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongoid-3.1.7 spec/mongoid/matchers/all_spec.rb
mongoid-3.1.6 spec/mongoid/matchers/all_spec.rb
mongoid-3.1.5 spec/mongoid/matchers/all_spec.rb