Class: CachingMatcher::BeExpiredMatcher

Inherits:
MatcherBase show all
Defined in:
lib/caching_matcher/caching_matcher.rb

Instance Attribute Summary

Attributes inherited from MatcherBase

#cache_key

Instance Method Summary collapse

Methods inherited from MatcherBase

#initialize

Constructor Details

This class inherits a constructor from CachingMatcher::MatcherBase

Instance Method Details

#failure_message_for_shouldObject



78
79
80
81
82
83
84
# File 'lib/caching_matcher/caching_matcher.rb', line 78

def failure_message_for_should
  if !@before
    "Key: #{@cache_key} was not cached before operation but should have been.  Did you forget to prime the cache?"
  elsif @after
    "Key: #{@cache_key} was cached after operation but should not have been."
  end
end

#failure_message_for_should_notObject



86
87
88
89
90
91
92
# File 'lib/caching_matcher/caching_matcher.rb', line 86

def failure_message_for_should_not
  if @before
    "Key: #{@cache_key} was cached before operation but should not have been.  Did you forget to clear the cache in a before block?"
  elsif !@after
    "Key: #{@cache_key} was not cached after operation but should have been."
  end
end

#matches?(event_proc) ⇒ Boolean

Returns:

  • (Boolean)


74
75
76
77
# File 'lib/caching_matcher/caching_matcher.rb', line 74

def matches?(event_proc)
  run_match(event_proc)
  @before && !@after
end