Sha256: b37a5dcc3b1b578a7ab1b07f51f05b77c0af05a870826b46878c419133d87aad

Contents?: true

Size: 932 Bytes

Versions: 21

Compression:

Stored size: 932 Bytes

Contents

require 'gecko'

class Gecko::Helpers::InspectionHelperTest < Minitest::Test
  def setup
    @klass = Class.new(Gecko::Record::Base) do
      attribute :published_date,     Date
      attribute :published_datetime, DateTime
      attribute :published_time,     Time
    end
    @client = Gecko::Client.new('ABC', 'DEF')
  end

  def test_inspect_times
    record = @klass.new(@client, {
      published_date: Date.new(2014),
      published_time: Time.new(2014),
      published_datetime: DateTime.new(2014),
    })
    assert_equal("2014-01-01 00:00:00", get_timestamp(record.inspect, :published_time))
    assert_equal("2014-01-01 00:00:00", get_timestamp(record.inspect, :published_datetime))
    assert_equal("2014-01-01",          get_timestamp(record.inspect, :published_date))
  end

  def get_timestamp(inspect_string, attribute)
    inspect_string.match(%r|#{attribute}: \"(?<timestamp>[\d:\s-]+)\"|)[:timestamp]
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
gecko-ruby-0.9.1 test/helpers/inspection_helper_test.rb
gecko-ruby-0.9.0 test/helpers/inspection_helper_test.rb
gecko-ruby-0.8.0 test/helpers/inspection_helper_test.rb
gecko-ruby-0.2.6 test/helpers/inspection_helper_test.rb
gecko-ruby-0.7.1 test/helpers/inspection_helper_test.rb
gecko-ruby-0.7.0 test/helpers/inspection_helper_test.rb
gecko-ruby-0.6.0 test/helpers/inspection_helper_test.rb
gecko-ruby-0.5.0 test/helpers/inspection_helper_test.rb
gecko-ruby-0.2.5 test/helpers/inspection_helper_test.rb
gecko-ruby-0.2.4 test/helpers/inspection_helper_test.rb
gecko-ruby-0.2.3 test/helpers/inspection_helper_test.rb
gecko-ruby-0.2.2 test/helpers/inspection_helper_test.rb
gecko-ruby-0.2.0 test/helpers/inspection_helper_test.rb
gecko-ruby-0.1.0 test/helpers/inspection_helper_test.rb
gecko-ruby-0.0.10 test/helpers/inspection_helper_test.rb
gecko-ruby-0.0.9 test/helpers/inspection_helper_test.rb
gecko-ruby-0.0.8 test/helpers/inspection_helper_test.rb
gecko-ruby-0.0.7 test/helpers/inspection_helper_test.rb
gecko-ruby-0.0.6 test/helpers/inspection_helper_test.rb
gecko-ruby-0.0.5 test/helpers/inspection_helper_test.rb