Sha256: 1ec3426daae5fca1855084552361b18ee2339222a98c97fc6c846e9e3e893c92

Contents?: true

Size: 995 Bytes

Versions: 73

Compression:

Stored size: 995 Bytes

Contents

require "spec_helper"

describe Mongoid::Errors::Validations do

  describe "#message" do

    let(:errors) do
      double(full_messages: [ "Error 1", "Error 2" ], empty?: false)
    end

    let(:document) do
      double(errors: errors, class: Person)
    end

    let(:error) do
      described_class.new(document)
    end

    it "contains the problem in the message" do
      expect(error.message).to include(
        "Validation of Person failed"
      )
    end

    it "contains the summary in the message" do
      expect(error.message).to include(
        "The following errors were found: Error 1, Error 2"
      )
    end

    it "contains the resolution in the message" do
      expect(error.message).to include(
        "Try persisting the document with valid data"
      )
    end

    it "sets the document in the error" do
      expect(error.document).to eq(document)
    end

    it "aliases record to document" do
      expect(error.record).to eq(document)
    end
  end
end

Version data entries

73 entries across 68 versions & 6 rubygems

Version Path
mongoid-7.0.13 spec/mongoid/errors/validations_spec.rb
mongoid-7.0.12 spec/mongoid/errors/validations_spec.rb
mongoid-6.4.8 spec/mongoid/errors/validations_spec.rb
mongoid-7.0.11 spec/mongoid/errors/validations_spec.rb
mongoid-7.0.10 spec/mongoid/errors/validations_spec.rb
mongoid-6.4.7 spec/mongoid/errors/validations_spec.rb
mongoid-6.4.5 spec/mongoid/errors/validations_spec.rb
mongoid-7.0.8 spec/mongoid/errors/validations_spec.rb
mongoid-7.0.7 spec/mongoid/errors/validations_spec.rb
mongoid-7.0.6 spec/mongoid/errors/validations_spec.rb
mongoid-5.4.1 spec/mongoid/errors/validations_spec.rb
mongoid-7.0.5 spec/mongoid/errors/validations_spec.rb
mongoid-7.0.4 spec/mongoid/errors/validations_spec.rb
mongoid-6.4.4 spec/mongoid/errors/validations_spec.rb
mongoid-7.0.3 spec/mongoid/errors/validations_spec.rb
mongoid-6.4.2 spec/mongoid/errors/validations_spec.rb
mongoid-7.0.2 spec/mongoid/errors/validations_spec.rb
mongoid-7.0.1 spec/mongoid/errors/validations_spec.rb
mongoid-6.4.1 spec/mongoid/errors/validations_spec.rb
mongoid-5.4.0 spec/mongoid/errors/validations_spec.rb