Class: Spec::Rails::Matchers::Observe
- Inherits:
-
Object
- Object
- Spec::Rails::Matchers::Observe
- Defined in:
- lib/spec/rails/matchers/observers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(expected_model_class) ⇒ Observe
constructor
A new instance of Observe.
- #matches?(observer) ⇒ Boolean
Constructor Details
#initialize(expected_model_class) ⇒ Observe
Returns a new instance of Observe.
6 7 8 |
# File 'lib/spec/rails/matchers/observers.rb', line 6 def initialize(expected_model_class) @expected_model_class = expected_model_class end |
Instance Method Details
#description ⇒ Object
23 24 25 |
# File 'lib/spec/rails/matchers/observers.rb', line 23 def description "observer to be observing #{@expected_model_class.name}" end |
#failure_message ⇒ Object
19 20 21 |
# File 'lib/spec/rails/matchers/observers.rb', line 19 def return "expected #{@observer.name} to observe #{@expected_model_class.name}, but it was not included in [#{@observed_classes.map(&:name).join(', ')}]" end |
#matches?(observer) ⇒ Boolean
10 11 12 13 14 15 16 17 |
# File 'lib/spec/rails/matchers/observers.rb', line 10 def matches?(observer) @observer = observer if @observer.is_a?(ActiveRecord::Observer) @observer = @observer.class end @observed_classes = observer.observed_classes.flatten @observed_classes.include?(@expected_model_class) end |