Class: Plyushkin::Test::PersistedAttributeMatcher
- Inherits:
-
MatcherBase
- Object
- MatcherBase
- Plyushkin::Test::PersistedAttributeMatcher
- Defined in:
- lib/plyushkin/test/persisted_attribute_matcher.rb
Defined Under Namespace
Classes: WithFormatMatcher
Instance Method Summary collapse
-
#initialize(attr_name) ⇒ PersistedAttributeMatcher
constructor
A new instance of PersistedAttributeMatcher.
- #matches?(subject) ⇒ Boolean
- #with_format(formatter) ⇒ Object
Methods inherited from MatcherBase
#description, #failure_message, #matchers, #negative_failure_message
Constructor Details
#initialize(attr_name) ⇒ PersistedAttributeMatcher
Returns a new instance of PersistedAttributeMatcher.
3 4 5 |
# File 'lib/plyushkin/test/persisted_attribute_matcher.rb', line 3 def initialize(attr_name) @attr_name = attr_name end |
Instance Method Details
#matches?(subject) ⇒ Boolean
12 13 14 15 16 |
# File 'lib/plyushkin/test/persisted_attribute_matcher.rb', line 12 def matches?(subject) @failure_message = "Plyushkin: no persisted attribute with name '#{@attr_name}'" unless subject.class.persisted_attributes.include?(@attr_name) @negative_failure_message = "Plyushkin: persisted attribute with name '#{@attr_name}' exists" unless subject.class.persisted_attributes.include?(@attr_name) super end |
#with_format(formatter) ⇒ Object
7 8 9 10 |
# File 'lib/plyushkin/test/persisted_attribute_matcher.rb', line 7 def with_format(formatter) matchers << WithFormatMatcher.new(@attr_name, formatter) self end |