class Shoulda::Lotus::Matchers::CoerceAttributeMatcher
Constants
- TYPES
Public Class Methods
new(attribute)
click to toggle source
# File lib/shoulda/lotus/matchers/coerce_attribute_matcher.rb, line 25 def initialize(attribute) @attribute = attribute end
Public Instance Methods
description()
click to toggle source
# File lib/shoulda/lotus/matchers/coerce_attribute_matcher.rb, line 34 def description "coerce '#{@attribute}' to '#{@type}'" end
failure_message()
click to toggle source
# File lib/shoulda/lotus/matchers/coerce_attribute_matcher.rb, line 38 def failure_message "does coerce '#{@attribute}' to '#{@type}'" end
failure_message_when_negated()
click to toggle source
# File lib/shoulda/lotus/matchers/coerce_attribute_matcher.rb, line 42 def failure_message_when_negated "does not coerce '#{@attribute}' to '#{@type}'" end
matches?(target)
click to toggle source
# File lib/shoulda/lotus/matchers/coerce_attribute_matcher.rb, line 29 def matches?(target) target.send("#{@attribute}=", TYPES[@type.to_s].first) target.send(@attribute) == TYPES[@type.to_s].last end
to(type)
click to toggle source
# File lib/shoulda/lotus/matchers/coerce_attribute_matcher.rb, line 46 def to(type) @type = type self end