Sha256: 75786b231a31c1b93d8f44d6584c5eb0e86c20f5431f23fe5fde8140159ecc0a

Contents?: true

Size: 1.76 KB

Versions: 18

Compression:

Stored size: 1.76 KB

Contents

require "spec_helper"

describe Mongoid::Errors do

  describe Mongoid::Errors::DocumentNotFound do

    describe "#message" do

      context "default" do

        before do
          @error = Mongoid::Errors::DocumentNotFound.new(Person, "3")
        end

        it "contains document not found" do
          @error.message.should include("Document not found")
        end

      end

    end

  end

  describe Mongoid::Errors::InvalidOptions do

    describe "#message" do

      context "default" do

        before do
          @error = Mongoid::Errors::InvalidOptions.new
        end

        it "returns the class name" do
          @error.message.should == @error.class.name
        end

      end

    end

  end

  describe Mongoid::Errors::InvalidDatabase do

    describe "#message" do

      before do
        @error = Mongoid::Errors::InvalidDatabase.new("Test")
      end

      it "returns a message with the bad db object class" do
        @error.message.should include("String")
      end

    end

  end

  describe Mongoid::Errors::Validations do

    describe "#message" do

      context "default" do

        before do
          @errors = stub(:full_messages => "Testing")
          @error = Mongoid::Errors::Validations.new(@errors)
        end

        it "contains the errors' full messages" do
          @error.message.should include("Testing")
        end

      end

    end

  end

  describe Mongoid::Errors::InvalidCollection do

    describe "#message" do

      context "default" do

        before do
          @klass = Address
          @error = Mongoid::Errors::InvalidCollection.new(@klass)
        end

        it "contains class is not allowed" do
          @error.message.should include("Address is not allowed")
        end

      end

    end

  end

end

Version data entries

18 entries across 18 versions & 2 rubygems

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