Sha256: 79d133c33d627eee1a34c15beb56a00232dc8f43fadc83358d501d05b88d217f

Contents?: true

Size: 1.09 KB

Versions: 24

Compression:

Stored size: 1.09 KB

Contents

require "spec_helper"

describe Mongoid::Matchers::Exists do

  describe "#matches?" do

    context "when checking for existence" do

      context "when the value exists" do

        let(:matcher) { Mongoid::Matchers::Exists.new("Test") }

        it "returns true" do
          matcher.matches?("$exists" => true).should be_true
        end

      end

      context "when the value does not exist" do

        let(:matcher) { Mongoid::Matchers::Exists.new(nil) }

        it "returns false" do
          matcher.matches?("$exists" => true).should be_false
        end

      end

    end

    context "when checking for nonexistence" do

      context "when the value exists" do

        let(:matcher) { Mongoid::Matchers::Exists.new("Test") }

        it "returns false" do
          matcher.matches?("$exists" => false).should be_false
        end

      end

      context "when the value does not exist" do

        let(:matcher) { Mongoid::Matchers::Exists.new(nil) }

        it "returns true" do
          matcher.matches?("$exists" => false).should be_true
        end

      end
    end

  end

end

Version data entries

24 entries across 24 versions & 3 rubygems

Version Path
mongoid-locomotive-2.0.0.beta9 spec/unit/mongoid/matchers/exists_spec.rb
mongoid-pre-2.0.0.beta1 spec/unit/mongoid/matchers/exists_spec.rb
mongoid-2.0.0.alpha spec/unit/mongoid/matchers/exists_spec.rb
mongoid-1.2.14 spec/unit/mongoid/matchers/exists_spec.rb
mongoid-1.2.13 spec/unit/mongoid/matchers/exists_spec.rb
mongoid-1.2.12 spec/unit/mongoid/matchers/exists_spec.rb
mongoid-1.2.11 spec/unit/mongoid/matchers/exists_spec.rb
mongoid-1.2.10 spec/unit/mongoid/matchers/exists_spec.rb
mongoid-1.2.9 spec/unit/mongoid/matchers/exists_spec.rb
mongoid-1.2.8 spec/unit/mongoid/matchers/exists_spec.rb
mongoid-1.2.7 spec/unit/mongoid/matchers/exists_spec.rb
mongoid-pre-2.0.0.pre spec/unit/mongoid/matchers/exists_spec.rb
mongoid-1.2.6 spec/unit/mongoid/matchers/exists_spec.rb
mongoid-1.2.5 spec/unit/mongoid/matchers/exists_spec.rb
mongoid-1.2.4 spec/unit/mongoid/matchers/exists_spec.rb
mongoid-1.2.3 spec/unit/mongoid/matchers/exists_spec.rb
mongoid-1.2.2 spec/unit/mongoid/matchers/exists_spec.rb
mongoid-1.2.1 spec/unit/mongoid/matchers/exists_spec.rb
mongoid-1.2.0 spec/unit/mongoid/matchers/exists_spec.rb
mongoid-1.1.4 spec/unit/mongoid/matchers/exists_spec.rb