Class: SwissKnife::RSpec::Matchers::HaveErrorOn

Inherits:
Object
  • Object
show all
Defined in:
lib/swiss_knife/rspec/have_error_on.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attributeObject

Returns the value of attribute attribute.



11
12
13
# File 'lib/swiss_knife/rspec/have_error_on.rb', line 11

def attribute
  @attribute
end

#subjectObject

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

#descriptionObject



22
23
24
# File 'lib/swiss_knife/rspec/have_error_on.rb', line 22

def description
  "have errors on #{attribute.inspect}"
end

#failure_messageObject



26
27
28
# File 'lib/swiss_knife/rspec/have_error_on.rb', line 26

def failure_message
  "expected #{subject.inspect} to have errors on #{attribute.inspect}"
end

#matches?(subject) ⇒ Boolean

Returns:

  • (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_messageObject



30
31
32
# File 'lib/swiss_knife/rspec/have_error_on.rb', line 30

def negative_failure_message
  "expected #{subject.inspect} to have no errors on #{attribute.inspect}"
end