Sha256: a6b948859de7186e8814035365ca7dffa7ca8535ca0f3b43613fe4b61e2e6c87

Contents?: true

Size: 863 Bytes

Versions: 1

Compression:

Stored size: 863 Bytes

Contents

require 'timezone/rule'
require 'minitest/autorun'

describe Timezone::Rule do
  before do
    Timezone.rules.clear
    @rule = Timezone::Rule.new('Zion')
  end

  it 'adds itself to the rules' do
    assert_equal ['Zion'], Timezone.rules.keys
  end

  it 'adds multiple rules with the same name' do
    Timezone::Rule.new('Zion')
    assert_equal 2, Timezone.rules['Zion'].count
  end

  describe '#offset' do
    it 'properly calculates hours' do
      @rule.save = '1:00'
      assert_equal 3_600, @rule.offset
    end

    it 'properly calculates minutes' do
      @rule.save = '2:20'
      assert_equal 8_400, @rule.offset
    end
  end

  describe '#dst?' do
    it 'knows standard time' do
      @rule.letter = 'S'
      assert !@rule.dst?
    end

    it 'knows daylight savings time' do
      @rule.letter = 'D'
      assert @rule.dst?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timezone-0.2.1 test/rule_test.rb