Sha256: bd5b095de842837b4ddfd1b7b71e2822f6e3216c40bb70675ba387f383bb7464

Contents?: true

Size: 920 Bytes

Versions: 56

Compression:

Stored size: 920 Bytes

Contents

require File.dirname(__FILE__) + '/../abstract_unit'

class DurationTest < Test::Unit::TestCase
  def test_inspect
    assert_equal '1 month',                         1.month.inspect
    assert_equal '1 month and 1 day',               (1.month + 1.day).inspect
    assert_equal '6 months and -2 days',            (6.months - 2.days).inspect
    assert_equal '10 seconds',                      10.seconds.inspect
    assert_equal '10 years, 2 months, and 1 day',   (10.years + 2.months + 1.day).inspect
    assert_equal '7 days',                          1.week.inspect
    assert_equal '14 days',                         1.fortnight.inspect
  end
  
  def test_minus_with_duration_does_not_break_subtraction_of_date_from_date
    assert_nothing_raised { Date.today - Date.today }
  end
  
  def test_plus_with_time
    assert_equal 1 + 1.second, 1.second + 1, "Duration + Numeric should == Numeric + Duration"
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
backlog-0.5.0 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.4.0 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.5.1 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.5.10 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.5.2 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.5.4 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.5.3 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.5.5 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.5.6 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.5.7 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.5.8 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.5.9 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.6.2 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.6.1 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.6.0 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.6.5 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.6.3 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.6.4 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.7.0 vendor/rails/activesupport/test/core_ext/duration_test.rb
backlog-0.6.6 vendor/rails/activesupport/test/core_ext/duration_test.rb