Library providing tools for writing and running RSpec tests.
Matcher for testing ActiveModel object validations.
DEFAULT_EXPECTED_ITEMS
= Object.new
#initialize => HaveErrorsMatcher
#actual => Object (readonly)
#description => Object
#does_not_match? actual => Boolean
Checks if the object can be validated, whether the object is valid, and checks the errors on the object against the expected errors and messages from #on and #with_message, if any.
#failure_message => Object
Message for when the object does not match, but was expected to. Make sure to always call #matches? first to set up the matcher state.
#failure_message_when_negated => Object
Message for when the object matches, but was expected not to. Make sure to always call #matches? first to set up the matcher state.
#matches? actual => Boolean
Checks if the object can be validated, whether the object is valid, and checks the errors on the object against the expected errors and messages from #on and #with_message, if any.
#on attribute => HaveErrorsMatcher
Adds an error expectation. If the actual object does not have an error on the specified attribute, #matches? will return false.
Setting an error expectation
expect(actual).to have_errors.on(:foo)
#with_message message => HaveErrorsMatcher
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.
Setting an error and a message expectation
expect(actual).to have_errors.on(:foo).with("can't be blank")
#with_messages => Object
Also known as:
with
Adds a set of message expectations for the most recently added error attribute.
Back to Documentation | Versions | 2.8 | Reference | RSpec | RSpec::SleepingKingStudios | RSpec::SleepingKingStudios::Matchers | RSpec::SleepingKingStudios::Matchers::ActiveModel