Class: RSpec::SleepingKingStudios::Matchers::ActiveModel::HaveErrors::ErrorExpectation
- Inherits:
-
Struct
- Object
- Struct
- RSpec::SleepingKingStudios::Matchers::ActiveModel::HaveErrors::ErrorExpectation
- Defined in:
- lib/rspec/sleeping_king_studios/matchers/active_model/have_errors/error_expectation.rb
Overview
Stores an expectation of receiving an error for a specified attribute, as well as zero or more message expectations.
Defined Under Namespace
Modules: MessagesMethods
Instance Attribute Summary collapse
-
#attribute ⇒ Object
Returns the value of attribute attribute.
-
#expected ⇒ Object
Returns the value of attribute expected.
-
#messages ⇒ Array<MessageExpectation>
readonly
The message expectations for the specified attribute.
-
#received ⇒ Object
Returns the value of attribute received.
Instance Method Summary collapse
-
#initialize(attribute, expected = true, received = false) ⇒ ErrorExpectation
constructor
A new instance of ErrorExpectation.
Constructor Details
#initialize(attribute, expected = true, received = false) ⇒ ErrorExpectation
Returns a new instance of ErrorExpectation.
41 42 43 44 45 46 47 48 |
# File 'lib/rspec/sleeping_king_studios/matchers/active_model/have_errors/error_expectation.rb', line 41 def initialize attribute, expected = true, received = false super attribute.intern, expected, received @messages = [] class << @messages include MessagesMethods end # eigenclass end |
Instance Attribute Details
#attribute ⇒ Object
Returns the value of attribute attribute
13 14 15 |
# File 'lib/rspec/sleeping_king_studios/matchers/active_model/have_errors/error_expectation.rb', line 13 def attribute @attribute end |
#expected ⇒ Object
Returns the value of attribute expected
13 14 15 |
# File 'lib/rspec/sleeping_king_studios/matchers/active_model/have_errors/error_expectation.rb', line 13 def expected @expected end |
#messages ⇒ Array<MessageExpectation> (readonly)
The message expectations for the specified attribute. The returned array supports several additional methods: #expected, #missing, and #received.
58 59 60 |
# File 'lib/rspec/sleeping_king_studios/matchers/active_model/have_errors/error_expectation.rb', line 58 def @messages end |
#received ⇒ Object
Returns the value of attribute received
13 14 15 |
# File 'lib/rspec/sleeping_king_studios/matchers/active_model/have_errors/error_expectation.rb', line 13 def received @received end |