Sha256: 79ac0569905318d303b6a88f7f30736f8491f7a4fbabd27ef343ac014ea28090

Contents?: true

Size: 813 Bytes

Versions: 2

Compression:

Stored size: 813 Bytes

Contents

require File.expand_path("../test_helper", __dir__)
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-2.0.0.beta2 test/search_flip/to_json_test.rb
search_flip-2.0.0.beta test/search_flip/to_json_test.rb