Sha256: 9f5a528b2b87feae1eccdce7e2d43710e3f911b4799f0c0bf2998621d73e3e79

Contents?: true

Size: 638 Bytes

Versions: 6

Compression:

Stored size: 638 Bytes

Contents

require 'spec_helper'
require 'parameters/types/time'

describe Parameters::Types::Time do
  subject { described_class }

  describe "coerce" do
    let(:string)    { '2011-12-03 19:39:09 -0800' }
    let(:timestamp) { 1322969949                  }
    let(:time)      { Time.at(1322969949)         }
    let(:date)      { DateTime.parse(string)      }

    it "should accept Integers" do
      subject.coerce(timestamp).should == time
    end

    it "should call #to_time when possible" do
      subject.coerce(date).should == time
    end

    it "should parse Strings" do
      subject.coerce(string).should == time
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
parameters-0.4.4 spec/types/time_spec.rb
parameters-0.4.3 spec/types/time_spec.rb
parameters-0.4.2 spec/types/time_spec.rb
parameters-0.4.0 spec/types/time_spec.rb
parameters-0.3.1 spec/types/time_spec.rb
parameters-0.3.0 spec/types/time_spec.rb