diff options
Diffstat (limited to 'activesupport/lib/active_support/testing')
| -rw-r--r-- | activesupport/lib/active_support/testing/declarative.rb | 17 | ||||
| -rw-r--r-- | activesupport/lib/active_support/testing/time_helpers.rb | 8 |
2 files changed, 16 insertions, 9 deletions
diff --git a/activesupport/lib/active_support/testing/declarative.rb b/activesupport/lib/active_support/testing/declarative.rb index 1fa73caefa..c349bb5fb1 100644 --- a/activesupport/lib/active_support/testing/declarative.rb +++ b/activesupport/lib/active_support/testing/declarative.rb @@ -7,11 +7,18 @@ module ActiveSupport unless method_defined?(:describe) def self.describe(text) - class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 - def self.name - "#{text}" - end - RUBY_EVAL + if block_given? + super + else + message = "`describe` without a block is deprecated, please switch to: `def self.name; #{text.inspect}; end`\n" + ActiveSupport::Deprecation.warn message + + class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 + def self.name + "#{text}" + end + RUBY_EVAL + end end end diff --git a/activesupport/lib/active_support/testing/time_helpers.rb b/activesupport/lib/active_support/testing/time_helpers.rb index a95ba21ba4..94230e56ba 100644 --- a/activesupport/lib/active_support/testing/time_helpers.rb +++ b/activesupport/lib/active_support/testing/time_helpers.rb @@ -3,8 +3,8 @@ module ActiveSupport # Containing helpers that helps you test passage of time. module TimeHelpers # Change current time to the time in the future or in the past by a given time difference by - # stubbing +Time.now+ and +Date.today+. This method also accepts a block, which will return - # current time back to its original state at the end of the block. + # stubbing +Time.now+ and +Date.today+. Note that the stubs are automatically removed + # at the end of each test. # # Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00 # travel 1.day @@ -24,8 +24,8 @@ module ActiveSupport end # Change current time to the given time by stubbing +Time.now+ and +Date.today+ to return the - # time or date passed into this method. This method also accepts a block, which will return - # current time back to its original state at the end of the block. + # time or date passed into this method. Note that the stubs are automatically removed + # at the end of each test. # # Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00 # travel_to Time.new(2004, 11, 24, 01, 04, 44) |
