Sha256: e5568f03e12a5ef51fe18d7b48208d6498bc702f70ca6cb427f2fe855477320c

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require "test_helper"

describe PlayWhe::Util do
  subject { PlayWhe::Util }

  describe "::normalize_year" do
    it "returns the last 2 digits of the year" do
      inputs = [1994, 94, 2016, 16]
      outputs = %w(94 94 16 16)

      inputs.zip(outputs).each do |input, output|
        expect(subject.normalize_year(input)).must_equal output
        expect(subject.normalize_year(input.to_s)).must_equal output
      end
    end
  end

  describe "::normalize_month" do
    describe "when given a number in the range 1 to 12" do
      it "returns the abbreviated month name" do
        inputs = 1..12
        outputs = %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)

        inputs.zip(outputs).each do |input, output|
          expect(subject.normalize_month(input)).must_equal output
          expect(subject.normalize_month(input.to_s)).must_equal output
        end
      end
    end

    describe "when given nil" do
      it "returns nil" do
        expect(subject.normalize_month(nil)).must_be_nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
playwhe-0.2.0 test/playwhe/util_test.rb