Created
June 18, 2012 18:32
-
-
Save rmw/2949882 to your computer and use it in GitHub Desktop.
Using tap to DRY up Rspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cache_should_receive_fetch(return_val = nil) | |
Rails.cache.should_receive(:fetch). | |
with(cache_key, { :race_condition_ttl => 10}). | |
tap { |o| o.and_return(return_val) unless return_val.nil? } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment