Sha256: 5cbb2f840bbc656ab737a915ed17c2041f4e5a63afca4116a34145bb5ffd25d4

Contents?: true

Size: 769 Bytes

Versions: 9

Compression:

Stored size: 769 Bytes

Contents

require File.join(File.dirname(__FILE__), "/../../../../spec_helper.rb")

describe Mongoid::Extensions::Date::Conversions do

  before do
    @time = Date.today.to_time.utc
  end

  describe "#set" do

    context "when string provided" do

      it "returns a time from the string" do
        Date.set(@time.to_s).should == @time
      end

    end

    context "when time provided" do

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

    end

    context "when a date provided" do

      it "returns a time from the date" do
        Date.set(@time.to_date).should == @time
      end

    end

  end

  describe "#get" do

    it "converts the time back to a date" do
      Date.get(@time).should == @time.to_date
    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mongoid-0.6.2 spec/unit/mongoid/extensions/date/conversions_spec.rb
mongoid-0.6.1 spec/unit/mongoid/extensions/date/conversions_spec.rb
mongoid-0.6.0 spec/unit/mongoid/extensions/date/conversions_spec.rb
mongoid-0.5.11 spec/unit/mongoid/extensions/date/conversions_spec.rb
mongoid-0.5.10 spec/unit/mongoid/extensions/date/conversions_spec.rb
mongoid-0.5.9 spec/unit/mongoid/extensions/date/conversions_spec.rb
mongoid-0.5.8 spec/unit/mongoid/extensions/date/conversions_spec.rb
mongoid-0.5.7 spec/unit/mongoid/extensions/date/conversions_spec.rb
mongoid-0.5.6 spec/unit/mongoid/extensions/date/conversions_spec.rb