diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-01-29 21:10:10 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-01-29 21:23:14 -0200 |
commit | 6dce4367c2bba894bb94e27cdfe4c56fdcc2c3df (patch) | |
tree | 3d1f4f664bcd78c9b09297a1e1b12bb6969a118c /activesupport/lib | |
parent | 049a10d4051a48136199fcdfd77bf35df9e9ad11 (diff) | |
download | rails-6dce4367c2bba894bb94e27cdfe4c56fdcc2c3df.tar.gz rails-6dce4367c2bba894bb94e27cdfe4c56fdcc2c3df.tar.bz2 rails-6dce4367c2bba894bb94e27cdfe4c56fdcc2c3df.zip |
Use instance method instead of before hook
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/testing/time_helpers.rb | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/activesupport/lib/active_support/testing/time_helpers.rb b/activesupport/lib/active_support/testing/time_helpers.rb index cd56ae1883..77b8ba261e 100644 --- a/activesupport/lib/active_support/testing/time_helpers.rb +++ b/activesupport/lib/active_support/testing/time_helpers.rb @@ -38,13 +38,8 @@ module ActiveSupport # Containing helpers that helps you test passage of time. module TimeHelpers - def before_setup - super - @simple_stubs = SimpleStubs.new - end - def after_teardown #:nodoc: - @simple_stubs.unstub_all! + simple_stubs.unstub_all! super end @@ -87,14 +82,18 @@ module ActiveSupport # end # Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00 def travel_to(date_or_time, &block) - @simple_stubs.stub_object(Time, :now, date_or_time.to_time) - @simple_stubs.stub_object(Date, :today, date_or_time.to_date) + simple_stubs.stub_object(Time, :now, date_or_time.to_time) + simple_stubs.stub_object(Date, :today, date_or_time.to_date) if block_given? block.call - @simple_stubs.unstub_all! + simple_stubs.unstub_all! end end + + def simple_stubs + @simple_stubs ||= SimpleStubs.new + end end end end |