Sha256: 0f719ca6794d046f9b2f9b0255eb39099c7fec76493d7fbbf05f785ef3bca4b1

Contents?: true

Size: 1.3 KB

Versions: 37

Compression:

Stored size: 1.3 KB

Contents

module Shoulda
  module Matchers
    module ActiveModel
      # @private
      class CouldNotDetermineValueOutsideOfArray < RuntimeError; end

      # @private
      class NonNullableBooleanError < Shoulda::Matchers::Error
        def self.create(attribute)
          super(attribute: attribute)
        end

        attr_accessor :attribute

        def message
          <<-EOT.strip
You have specified that your model's #{attribute} should ensure inclusion of nil.
However, #{attribute} is a boolean column which does not allow null values.
Hence, this test will fail and there is no way to make it pass.
          EOT
        end
      end

      # @private
      class CouldNotSetPasswordError < Shoulda::Matchers::Error
        def self.create(model)
          super(model: model)
        end

        attr_accessor :model

        def message
          <<-EOT.strip
The validation failed because your #{model_name} model declares `has_secure_password`, and
`validate_presence_of` was called on a #{record_name} which has `password` already set to a value.
Please use a #{record_name} with an empty `password` instead.
          EOT
        end

        private

        def model_name
          model.name
        end

        def record_name
          model_name.humanize.downcase
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 3 rubygems

Version Path
shoulda-matchers-6.4.0 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-6.3.1 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-6.3.0 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-6.2.0 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-6.1.0 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-6.0.0 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-5.3.0 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-5.2.0 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-5.1.0 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-5.0.0 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-5.0.0.rc1 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-4.5.1 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-4.5.0 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-4.4.1 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-4.4.0 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-4.3.0 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-4.2.0 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-4.1.2 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-4.1.1 lib/shoulda/matchers/active_model/errors.rb
shoulda-matchers-4.1.0 lib/shoulda/matchers/active_model/errors.rb