lib/rspec/sleeping_king_studios/matchers/active_model/have_errors_matcher.rb
# Adds a message expectation for the most recently added error attribute.
# If the actual object does not have an error on the that attribute with
# the specified message, #matches? will return false.
#
# @param [String, Regexp] message The expected error message. If a string,
#   matcher will check for an exact match; if a regular expression, matcher
#   will check if the message matches the regexp.
#
# @raise [ArgumentError] If no error attribute has been added.
#
# @return [HaveErrorsMatcher] self
#
# @example Setting an error and a message expectation
#   expect(actual).to have_errors.on(:foo).with("can't be blank")
#
# @see #on
Adds a message expectation for the most recently added error attribute.
If the actual object does not have an error on the that attribute with
the specified message, #matches. will return false.
Adds a message expectation for the most recently added error attribute . If the actual object does not have an error on the that attribute with the specified message #matches . will return false .
def with_message message
      raise ArgumentError.new "no attribute specified for error message" if
        @error_expectations.empty?
      @error_expectations.last.messages << MessageExpectation.new(message)
      self
    end
def with_message message raise ArgumentError . new "no attribute specified for error message" if @error_expectations . empty? @error_expectations . last . messages << MessageExpectation . new ( message ) self end
Adds a message expectation for the most recently added error attribute.
Adds a message expectation for the most recently added error attribute .
None
HaveErrorsMatcher
[ArgumentError] If no error attribute has been added.
[ ArgumentError ] If no error attribute has been added .
message
<not_specific>
<not_specific>
message The expected error message. If a string, matcher will check for an exact match; if a regular expression, matcher will check if the message matches the regexp.
message The expected error message . If a string matcher will check for an exact match ; if a regular expression matcher will check if the message matches the regexp .
example
Setting an error and a message expectation expect(actual).to have_errors.on(:foo).with("can't be blank")
Setting an error and a message expectation expect ( actual ) . to have_errors . on ( : foo ) . with ( " can ' t be blank " )
see
None