Exception: Shoulda::Matchers::ActiveModel::AllowValueMatcher::AttributeChangedValueError

Inherits:
Error
  • Object
show all
Defined in:
lib/shoulda/matchers/active_model/allow_value_matcher/attribute_changed_value_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Error

create, #initialize, #inspect

Constructor Details

This class inherits a constructor from Shoulda::Matchers::Error

Instance Attribute Details

#attribute_nameObject

Returns the value of attribute attribute_name.



7
8
9
# File 'lib/shoulda/matchers/active_model/allow_value_matcher/attribute_changed_value_error.rb', line 7

def attribute_name
  @attribute_name
end

#matcher_nameObject

Returns the value of attribute matcher_name.



7
8
9
# File 'lib/shoulda/matchers/active_model/allow_value_matcher/attribute_changed_value_error.rb', line 7

def matcher_name
  @matcher_name
end

#modelObject

Returns the value of attribute model.



7
8
9
# File 'lib/shoulda/matchers/active_model/allow_value_matcher/attribute_changed_value_error.rb', line 7

def model
  @model
end

#value_readObject

Returns the value of attribute value_read.



7
8
9
# File 'lib/shoulda/matchers/active_model/allow_value_matcher/attribute_changed_value_error.rb', line 7

def value_read
  @value_read
end

#value_writtenObject

Returns the value of attribute value_written.



7
8
9
# File 'lib/shoulda/matchers/active_model/allow_value_matcher/attribute_changed_value_error.rb', line 7

def value_written
  @value_written
end

Instance Method Details

#messageObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/shoulda/matchers/active_model/allow_value_matcher/attribute_changed_value_error.rb', line 10

def message
  Shoulda::Matchers.word_wrap "The \#{matcher_name} matcher attempted to set :\#{attribute_name} on\n\#{model.name} to \#{value_written.inspect}, but when the attribute was\nread back, it had stored \#{value_read.inspect} instead.\n\nThis creates a problem because it means that the model is behaving in a\nway that is interfering with the test -- there's a mismatch between the\ntest that you wrote and test that we actually ran.\n\nThere are a couple of reasons why this could be happening:\n\n* ActiveRecord is typecasting the incoming value.\n* The writer method for :\#{attribute_name} has been overridden so that\n  incoming values are changed in some way.\n\nIf this exception makes sense to you and you wish to bypass it, try\nadding the `ignoring_interference_by_writer` qualifier onto the end of\nyour matcher. If the test still does not pass after that, then you may\nneed to do something different.\n\nIf you need help, feel free to ask a question on the shoulda-matchers\nissues list:\n\nhttps://github.com/thoughtbot/shoulda-matchers/issues\n  MESSAGE\nend\n"

#successful?Boolean



38
39
40
# File 'lib/shoulda/matchers/active_model/allow_value_matcher/attribute_changed_value_error.rb', line 38

def successful?
  false
end