Skip to content

Commit

Permalink
Fix date conversion specs to expect utc times at midnight.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Durand authored and durran committed Apr 9, 2010
1 parent d485b37 commit 213d784
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions spec/unit/mongoid/extensions/date/conversions_spec.rb
Expand Up @@ -13,7 +13,8 @@
context "when string is a non utc time" do

it "returns a utc time from the string" do
Date.set(@time.to_s).should == @time.utc
time_in_millis = Time.at((@time.to_f * 1000).round / 1000)
Date.set(@time.to_s).should == time_in_millis.utc.at_midnight
end

end
Expand All @@ -22,7 +23,7 @@

it "returns a time from the string" do
date = RUBY_VERSION.start_with?("1.9") ? "15/01/2007" : "01/15/2007"
Date.set(date).should == Date.new(2007, 1, 15).at_midnight.utc
Date.set(date).should == Date.civil(2007, 1, 15).to_time.utc.at_midnight
end

end
Expand All @@ -39,16 +40,16 @@

context "when time provided" do

it "returns the time" do
Date.set(@time).should == @time.utc
it "returns the date for the time" do
Date.set(@time).should == @time.utc.at_midnight
end

end

context "when a date provided" do

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

end
Expand Down

0 comments on commit 213d784

Please sign in to comment.