Class: SwissKnife::RSpec::Matchers::HaveErrorOn
- Inherits:
-
Object
- Object
- SwissKnife::RSpec::Matchers::HaveErrorOn
- Defined in:
- lib/swiss_knife/rspec/have_error_on.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
Returns the value of attribute attribute.
-
#subject ⇒ Object
Returns the value of attribute subject.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(attribute) ⇒ HaveErrorOn
constructor
A new instance of HaveErrorOn.
- #matches?(subject) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(attribute) ⇒ HaveErrorOn
Returns a new instance of HaveErrorOn.
13 14 15 |
# File 'lib/swiss_knife/rspec/have_error_on.rb', line 13 def initialize(attribute) @attribute = attribute end |
Instance Attribute Details
#attribute ⇒ Object
Returns the value of attribute attribute.
11 12 13 |
# File 'lib/swiss_knife/rspec/have_error_on.rb', line 11 def attribute @attribute end |
#subject ⇒ Object
Returns the value of attribute subject.
11 12 13 |
# File 'lib/swiss_knife/rspec/have_error_on.rb', line 11 def subject @subject end |
Instance Method Details
#description ⇒ Object
22 23 24 |
# File 'lib/swiss_knife/rspec/have_error_on.rb', line 22 def description "have errors on #{attribute.inspect}" end |
#failure_message ⇒ Object
26 27 28 |
# File 'lib/swiss_knife/rspec/have_error_on.rb', line 26 def "expected #{subject.inspect} to have errors on #{attribute.inspect}" end |
#matches?(subject) ⇒ Boolean
17 18 19 20 |
# File 'lib/swiss_knife/rspec/have_error_on.rb', line 17 def matches?(subject) @subject = subject subject.errors[attribute.to_sym].any? end |
#negative_failure_message ⇒ Object
30 31 32 |
# File 'lib/swiss_knife/rspec/have_error_on.rb', line 30 def "expected #{subject.inspect} to have no errors on #{attribute.inspect}" end |