diff options
Diffstat (limited to 'activesupport/lib/active_support/testing')
12 files changed, 41 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb index 28e1df8870..d7bb5e5bdf 100644 --- a/activesupport/lib/active_support/testing/assertions.rb +++ b/activesupport/lib/active_support/testing/assertions.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module ActiveSupport module Testing module Assertions diff --git a/activesupport/lib/active_support/testing/autorun.rb b/activesupport/lib/active_support/testing/autorun.rb index a18788f38e..40ae696a34 100644 --- a/activesupport/lib/active_support/testing/autorun.rb +++ b/activesupport/lib/active_support/testing/autorun.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true gem "minitest" require "minitest" diff --git a/activesupport/lib/active_support/testing/constant_lookup.rb b/activesupport/lib/active_support/testing/constant_lookup.rb index 647395d2b3..a231697979 100644 --- a/activesupport/lib/active_support/testing/constant_lookup.rb +++ b/activesupport/lib/active_support/testing/constant_lookup.rb @@ -1,5 +1,6 @@ -require "active_support/concern" -require "active_support/inflector" +# frozen_string_literal: true +require_relative "../concern" +require_relative "../inflector" module ActiveSupport module Testing diff --git a/activesupport/lib/active_support/testing/declarative.rb b/activesupport/lib/active_support/testing/declarative.rb index 53ab3ebf78..601f6fb16d 100644 --- a/activesupport/lib/active_support/testing/declarative.rb +++ b/activesupport/lib/active_support/testing/declarative.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module ActiveSupport module Testing module Declarative diff --git a/activesupport/lib/active_support/testing/deprecation.rb b/activesupport/lib/active_support/testing/deprecation.rb index 58911570e8..1145afceff 100644 --- a/activesupport/lib/active_support/testing/deprecation.rb +++ b/activesupport/lib/active_support/testing/deprecation.rb @@ -1,5 +1,6 @@ -require "active_support/deprecation" -require "active_support/core_ext/regexp" +# frozen_string_literal: true +require_relative "../deprecation" +require_relative "../core_ext/regexp" module ActiveSupport module Testing diff --git a/activesupport/lib/active_support/testing/file_fixtures.rb b/activesupport/lib/active_support/testing/file_fixtures.rb index affb84cda5..56f80fb547 100644 --- a/activesupport/lib/active_support/testing/file_fixtures.rb +++ b/activesupport/lib/active_support/testing/file_fixtures.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module ActiveSupport module Testing # Adds simple access to sample files called file fixtures. diff --git a/activesupport/lib/active_support/testing/isolation.rb b/activesupport/lib/active_support/testing/isolation.rb index 54c3263efa..4d43c06085 100644 --- a/activesupport/lib/active_support/testing/isolation.rb +++ b/activesupport/lib/active_support/testing/isolation.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module ActiveSupport module Testing module Isolation diff --git a/activesupport/lib/active_support/testing/method_call_assertions.rb b/activesupport/lib/active_support/testing/method_call_assertions.rb index 6b07416fdc..d33224e9c3 100644 --- a/activesupport/lib/active_support/testing/method_call_assertions.rb +++ b/activesupport/lib/active_support/testing/method_call_assertions.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "minitest/mock" module ActiveSupport diff --git a/activesupport/lib/active_support/testing/setup_and_teardown.rb b/activesupport/lib/active_support/testing/setup_and_teardown.rb index 358c79c321..e80b8d17ef 100644 --- a/activesupport/lib/active_support/testing/setup_and_teardown.rb +++ b/activesupport/lib/active_support/testing/setup_and_teardown.rb @@ -1,5 +1,6 @@ -require "active_support/concern" -require "active_support/callbacks" +# frozen_string_literal: true +require_relative "../concern" +require_relative "../callbacks" module ActiveSupport module Testing diff --git a/activesupport/lib/active_support/testing/stream.rb b/activesupport/lib/active_support/testing/stream.rb index 1d06b94559..4e8303f058 100644 --- a/activesupport/lib/active_support/testing/stream.rb +++ b/activesupport/lib/active_support/testing/stream.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module ActiveSupport module Testing module Stream #:nodoc: diff --git a/activesupport/lib/active_support/testing/tagged_logging.rb b/activesupport/lib/active_support/testing/tagged_logging.rb index afdff87b45..3ca45b4ab5 100644 --- a/activesupport/lib/active_support/testing/tagged_logging.rb +++ b/activesupport/lib/active_support/testing/tagged_logging.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module ActiveSupport module Testing # Logs a "PostsControllerTest: test name" heading before each test to diff --git a/activesupport/lib/active_support/testing/time_helpers.rb b/activesupport/lib/active_support/testing/time_helpers.rb index 3d9ff99729..d72d82d7c4 100644 --- a/activesupport/lib/active_support/testing/time_helpers.rb +++ b/activesupport/lib/active_support/testing/time_helpers.rb @@ -1,5 +1,6 @@ -require "active_support/core_ext/string/strip" # for strip_heredoc -require "active_support/core_ext/time/calculations" +# frozen_string_literal: true +require_relative "../core_ext/string/strip" # for strip_heredoc +require_relative "../core_ext/time/calculations" require "concurrent/map" module ActiveSupport @@ -160,6 +161,27 @@ module ActiveSupport simple_stubs.unstub_all! end + # Calls `travel_to` with `Time.now`. + # + # Time.current # => Sun, 09 Jul 2017 15:34:49 EST -05:00 + # freeze_time + # sleep(1) + # Time.current # => Sun, 09 Jul 2017 15:34:49 EST -05:00 + # + # This method also accepts a block, which will return the current time back to its original + # state at the end of the block: + # + # Time.current # => Sun, 09 Jul 2017 15:34:49 EST -05:00 + # freeze_time do + # sleep(1) + # User.create.created_at # => Sun, 09 Jul 2017 15:34:49 EST -05:00 + # end + # Time.current # => Sun, 09 Jul 2017 15:34:50 EST -05:00 + + def freeze_time(&block) + travel_to Time.now, &block + end + private def simple_stubs |