Class: Plyushkin::Test::PersistedAttributeMatcher::WithFormatMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/plyushkin/test/persisted_attribute_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(attr_name, formatter) ⇒ WithFormatMatcher

Returns a new instance of WithFormatMatcher.



19
20
21
# File 'lib/plyushkin/test/persisted_attribute_matcher.rb', line 19

def initialize(attr_name, formatter)
  @attr_name, @formatter = attr_name, formatter
end

Instance Method Details

#failure_messageObject



27
28
29
# File 'lib/plyushkin/test/persisted_attribute_matcher.rb', line 27

def failure_message
  "Plyushkin: attribute #{@attr_name} is not formatting with #{@formatter}"
end

#match(subject) ⇒ Object



23
24
25
# File 'lib/plyushkin/test/persisted_attribute_matcher.rb', line 23

def match(subject)
  subject.class.formatters[@attr_name] == @formatter
end

#negative_failure_messageObject



31
32
33
# File 'lib/plyushkin/test/persisted_attribute_matcher.rb', line 31

def negative_failure_message
  "Plyushkin: attribute #{@attr_name} is formatting with #{@formatter}"
end