diff options
author | Xavier Noria <fxn@hashref.com> | 2014-02-18 10:22:43 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2014-02-18 10:25:11 +0100 |
commit | 5d037819ca80606638212f83de741cc2041db28f (patch) | |
tree | e6692777827b70641809d94f3b708c32140292e6 /activesupport/lib/active_support | |
parent | 24fa399c99316d8765c7ec374050b609e362b1c6 (diff) | |
download | rails-5d037819ca80606638212f83de741cc2041db28f.tar.gz rails-5d037819ca80606638212f83de741cc2041db28f.tar.bz2 rails-5d037819ca80606638212f83de741cc2041db28f.zip |
travel_to travels back and re-raises if the block raises
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/testing/time_helpers.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/testing/time_helpers.rb b/activesupport/lib/active_support/testing/time_helpers.rb index b36f3cf94c..eefa84262e 100644 --- a/activesupport/lib/active_support/testing/time_helpers.rb +++ b/activesupport/lib/active_support/testing/time_helpers.rb @@ -10,7 +10,7 @@ module ActiveSupport def stub_object(object, method_name, return_value) key = [object.object_id, method_name] - if (stub = @stubs[key]) + if stub = @stubs[key] unstub_object(stub) end @@ -97,8 +97,11 @@ module ActiveSupport simple_stubs.stub_object(Date, :today, now.to_date) if block_given? - block.call - travel_back + begin + block.call + ensure + travel_back + end end end |