Sha256: 3b1c9f4f5af2d1a3f0d638a9920010bdc42f88b03a4736310421acd4a1ba22ac

Contents?: true

Size: 817 Bytes

Versions: 2

Compression:

Stored size: 817 Bytes

Contents

require File.expand_path("../../test_helper", __FILE__)
require "search_flip/to_json"

class SearchFlip::ToJsonTest < SearchFlip::TestCase
  def test_time
    Timecop.freeze Time.parse("2018-01-01 12:00:00 UTC") do
      assert_equal "\"2018-01-01T12:00:00.000000Z\"", Time.now.utc.to_json
    end
  end

  def test_date
    Timecop.freeze Time.parse("2018-01-01 12:00:00 UTC") do
      assert_equal "\"2018-01-01\"", Date.today.to_json
    end
  end

  def test_date_time
    Timecop.freeze Time.parse("2018-01-01 12:00:00 UTC") do
      assert_equal "\"2018-01-01T12:00:00.000000Z\"", Time.now.utc.to_json
    end
  end

  def test_time_with_zone
    Timecop.freeze Time.parse("2018-01-01 12:00:00 UTC") do
      assert_equal "\"2018-01-01T12:00:00.000000Z\"", Time.find_zone("UTC").now.to_json
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
search_flip-1.1.0 test/search_flip/to_json_test.rb
search_flip-1.0.0 test/search_flip/to_json_test.rb