Sha256: 5a75ab1d60a1a0c94e049a38539cd8acd207b0cd3dbb5fc02af7d5ba1ef3bebb

Contents?: true

Size: 818 Bytes

Versions: 3

Compression:

Stored size: 818 Bytes

Contents

require "spec_helper"

describe Mongoid::Errors::InvalidField do

  describe "#message" do

    module MyModule
      def crazy_method; self; end
    end

    before do
      Object.send(:include, MyModule)
    end

    let(:error) do
      described_class.new(Person, :crazy_method)
    end

    it "contains the problem in the message" do
      error.message.should include(
        "Defining a field named 'crazy_method' is not allowed."
      )
    end

    it "contains the summary in the message" do
      error.message.should include(
        "Defining this field would override the method 'crazy_method'"
      )
    end

    it "contains the resolution in the message" do
      error.message.should include(
        "Use Mongoid.destructive_fields to see what names are not allowed"
      )
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongoid-3.1.7 spec/mongoid/errors/invalid_field_spec.rb
mongoid-3.1.6 spec/mongoid/errors/invalid_field_spec.rb
mongoid-3.1.5 spec/mongoid/errors/invalid_field_spec.rb