Sha256: 93df1f4128e5ee397b925158150d8cffc9277b9bc8d66478597ecb3345aec811

Contents?: true

Size: 790 Bytes

Versions: 13

Compression:

Stored size: 790 Bytes

Contents

require 'test_helper'

class Superstore::Types::TimeTypeTest < Superstore::Types::TestCase
  test 'encode' do
    assert_equal '2004-12-24T01:02:03.000000Z', type.encode(Time.utc(2004, 12, 24, 1, 2, 3))
    assert_equal '2004-12-24T01:02:03.000000Z', type.encode(DateTime.new(2004, 12, 24, 1, 2, 3))
    assert_raise ArgumentError do
      type.encode 123
    end
  end

  test 'decode' do
    assert_nil type.decode(nil)
    assert_nil type.decode('bad format')
    assert_equal Time.utc(2004, 12, 24, 1, 2, 3), type.decode('2004-12-24T01:02:03.000000Z')

    Time.use_zone 'Central Time (US & Canada)' do
      with_zone = type.decode('2013-07-18 13:12:46 -0700')
      assert_equal Time.utc(2013, 07, 18, 20, 12, 46), with_zone
      assert_equal 'CDT', with_zone.zone
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
superstore-2.4.4 test/unit/types/time_type_test.rb
superstore-2.4.3 test/unit/types/time_type_test.rb
superstore-2.4.2 test/unit/types/time_type_test.rb
superstore-2.4.1 test/unit/types/time_type_test.rb
superstore-2.4.0 test/unit/types/time_type_test.rb
superstore-2.3.0 test/unit/types/time_type_test.rb
superstore-2.2.0 test/unit/types/time_type_test.rb
superstore-2.1.3 test/unit/types/time_type_test.rb
superstore-2.1.2 test/unit/types/time_type_test.rb
superstore-2.1.1 test/unit/types/time_type_test.rb
superstore-2.1.0 test/unit/types/time_type_test.rb
superstore-2.0.1 test/unit/types/time_type_test.rb
superstore-2.0.0 test/unit/types/time_type_test.rb