Sha256: 7c1008be2eb3b85d683e0938d69b15ea8090c1b6e978e8e721adc959371a48ff

Contents?: true

Size: 1.08 KB

Versions: 32

Compression:

Stored size: 1.08 KB

Contents

require "spec_helper"

describe Mongoid::Extensions::Time::Conversions do

  before do
    Time.zone = "Canberra"
    @time = Time.local(1976, 11, 19)
  end

  after do
    Time.zone = nil
  end

  describe "#set" do

    context "when value is a string" do

      it "converts to a utc time" do
        Time.set(@time.to_s).utc_offset.should == 0
      end

    end

    context "when value is a time" do

      it "converts to a utc time" do
        Time.set(@time).utc_offset.should == 0
      end

    end

    context "when value is already a utc time" do

      it "returns the time" do
        Time.set(@time.utc).should == @time.utc
      end

    end

    context "when value is nil" do

      it "returns nil" do
        Time.set(nil).should be_nil
      end

    end

  end

  describe "#get" do

    context "when time is provided" do

      it "returns the local time" do
        Time.get(@time.dup.utc).utc_offset.should == @time.utc_offset
      end

    end

    context "when time is nil" do

      it "returns nil" do
        Time.get(nil).should be_nil
      end

    end

  end

end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
mongoid-pre-2.0.0.beta1 spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-2.0.0.alpha spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-1.2.14 spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-1.2.13 spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-1.2.12 spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-1.2.11 spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-1.2.10 spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-1.2.9 spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-1.2.8 spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-1.2.7 spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-pre-2.0.0.pre spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-1.2.6 spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-1.2.5 spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-1.2.4 spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-1.2.3 spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-1.2.2 spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-1.2.1 spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-1.2.0 spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-1.1.4 spec/unit/mongoid/extensions/time/conversions_spec.rb
mongoid-1.1.3 spec/unit/mongoid/extensions/time/conversions_spec.rb