Sha256: 4b61b3596708c65b0a92856c933ae6a6624e2f4e97f9eb8d036e2439063d8227

Contents?: true

Size: 797 Bytes

Versions: 14

Compression:

Stored size: 797 Bytes

Contents

require 'test_helper'

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

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

    Time.use_zone 'Central Time (US & Canada)' do
      with_zone = coder.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

14 entries across 14 versions & 1 rubygems

Version Path
superstore-1.2.0 test/unit/types/time_type_test.rb
superstore-1.1.4 test/unit/types/time_type_test.rb
superstore-1.1.3 test/unit/types/time_type_test.rb
superstore-1.1.2 test/unit/types/time_type_test.rb
superstore-1.1.1 test/unit/types/time_type_test.rb
superstore-1.1.0 test/unit/types/time_type_test.rb
superstore-1.0.12 test/unit/types/time_type_test.rb
superstore-1.0.11 test/unit/types/time_type_test.rb
superstore-1.0.10 test/unit/types/time_type_test.rb
superstore-1.0.9 test/unit/types/time_type_test.rb
superstore-1.0.8 test/unit/types/time_type_test.rb
superstore-1.0.7 test/unit/types/time_type_test.rb
superstore-1.0.6 test/unit/types/time_type_test.rb
superstore-1.0.5 test/unit/types/time_type_test.rb