RSpec

Library providing tools for writing and running RSpec tests.

Class: RSpec::SleepingKingStudios::Matchers::ActiveModel::HaveErrorsMatcher

Parent Namespace
RSpec::SleepingKingStudios::Matchers::ActiveModel
Inherited Classes
RSpec::SleepingKingStudios::Matchers::BaseMatcher > Object
Included Modules
RSpec::Matchers::Composable, RSpec::SleepingKingStudios::Matchers::ActiveModel::HaveErrors
Defined In
lib/rspec/sleeping_king_studios/matchers/active_model/have_errors_matcher.rb

Table Of Contents

Overview

Matcher for testing ActiveModel object validations.

Since

Back To Top

Constants

DEFAULT_EXPECTED_ITEMS

= Object.new

Inherited From
RSpec::SleepingKingStudios::Matchers::Description

Since

Back To Top

Constructor

#initialize => HaveErrorsMatcher

Returns

Since

Back To Top

Instance Attributes

#actual => Object (readonly)

Inherited From
RSpec::SleepingKingStudios::Matchers::BaseMatcher

Since

Back To Top

Instance Methods

#description => Object

Since

#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.

Parameters

Returns

See Also

Since

#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.

Since

#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.

Since

#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.

Parameters

Returns

See Also

Since

#on attribute => HaveErrorsMatcher

Adds an error expectation. If the actual object does not have an error on the specified attribute, #matches? will return false.

Examples

Setting an error expectation

expect(actual).to have_errors.on(:foo)

Parameters

Returns

Since

#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.

Examples

Setting an error and a message expectation

expect(actual).to have_errors.on(:foo).with("can't be blank")

Parameters

Returns

Raises

See Also

Since

#with_messages => Object

Also known as: with

Adds a set of message expectations for the most recently added error attribute.

Parameters

See Also

Since

Back To Top


Back to Documentation | Reference | RSpec | RSpec::SleepingKingStudios | RSpec::SleepingKingStudios::Matchers | RSpec::SleepingKingStudios::Matchers::ActiveModel