Created
August 18, 2014 11:44
-
-
Save dv/d2b7cfa5e6a13e4950be to your computer and use it in GitHub Desktop.
Easy Timecop in Rspec
This file contains hidden or 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
config.treat_symbols_as_metadata_keys_with_true_values = true | |
config.around(:each) do |example| | |
if example.metadata[:freeze_time] | |
Timecop.freeze(Time.now) | |
example.run | |
Timecop.return | |
end | |
end | |
# Usage: | |
describe User do | |
context "Something", :freeze_time do | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment