Class: Plyushkin::Test::HoardedAttributeMatcher::CallbackMatcher

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

Instance Method Summary collapse

Constructor Details

#initialize(attr_name, callback) ⇒ CallbackMatcher

Returns a new instance of CallbackMatcher.



76
77
78
# File 'lib/plyushkin/test/hoarded_attribute_matcher.rb', line 76

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

Instance Method Details

#failure_messageObject



85
86
87
# File 'lib/plyushkin/test/hoarded_attribute_matcher.rb', line 85

def failure_message
  message(true)
end

#match(subject) ⇒ Object



80
81
82
83
# File 'lib/plyushkin/test/hoarded_attribute_matcher.rb', line 80

def match(subject)
  callbacks = subject.class.plyushkin_model.callbacks[@attr_name]
  callbacks && (callbacks[:after_create] == @callback)
end

#message(negate) ⇒ Object



93
94
95
# File 'lib/plyushkin/test/hoarded_attribute_matcher.rb', line 93

def message(negate)
  "Plyushkin:: Hoarded attribute #{@attr_name} #{negate ? "does not callback" : "calls back"} #{@callback}"
end

#negative_failure_messageObject



89
90
91
# File 'lib/plyushkin/test/hoarded_attribute_matcher.rb', line 89

def negative_failure_message
  message(false)
end