Sha256: 2b6e610c50853f5e80d66c2a594c2a3adbf956bfcae89634b62a935875e03302

Contents?: true

Size: 967 Bytes

Versions: 1

Compression:

Stored size: 967 Bytes

Contents

# -*- coding: utf-8 -*-
require 'minitest/autorun'
require 'sixarm_ruby_to_id'

describe Hash do

  describe "#to_date_id casts to a date id" do

    describe "with fields for year, month, day #=> YYYY-MM-DD" do

      it "works with string keys" do
        {"year" => "2000", "month" => "12", "day" => "31"}.to_date_id.must_equal "2000-12-31"
      end

      it "works with symbol keys" do
        {year: "2000", month: "12", day: "31"}.to_date_id.must_equal "2000-12-31"
      end

    end

    describe "without fields for year, or month, or day #=> nil" do

      it "returns nil if it doesn't have a year" do
        {month: "12", day: "31"}.to_date_id.must_equal nil
      end
      
      it "returns nil if it doesn't have a month" do
        {year: "2000", day: "31"}.to_date_id.must_equal nil
      end
      
      it "returns nil if it doesn't have a day" do
        {year: "2000", month: "12"}.to_date_id.must_equal nil
      end

    end

  end

end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sixarm_ruby_to_id-1.0.6 test/sixarm_ruby_to_id_test/hash_test.rb