Skip to content

Commit

Permalink
Make time specs timezone independent
Browse files Browse the repository at this point in the history
* Changed spec to add getutc to lock specced time to UTC

* Time.now automagically converts to_local; this means the test suite
  passes in olbrich's timezone but not in the other 23/24ths of the
  Earth ;-)
  • Loading branch information
dbrady committed Apr 2, 2012
1 parent 365be2d commit e10cd0f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions spec/ruby-units/time_spec.rb
Expand Up @@ -8,23 +8,23 @@

context ".at" do
subject { Date.new(2011,4,1).to_unit }
specify { Time.at(subject - Date.new(1970,1,1)).strftime("%D %T").should == "03/31/11 20:00:00"}
specify { Time.at(subject - Date.new(1970,1,1)).getutc.strftime("%D %T").should == "04/01/11 00:00:00"}
specify { Time.at(subject - Date.new(1970,1,1), 500).usec.should == 500}
end

context ".in" do
specify { Time.in("5 min").should be_a Time}
specify { Time.in("5 min").should > Time.now}
end

context '#to_unit' do
subject { now }
its(:to_unit) { should be_an_instance_of(Unit) }
its('to_unit.units') { should == "s" }
specify { subject.to_unit('h').kind.should == :time}
specify { subject.to_unit('h').units.should == 'h'}
end

context 'addition (+)' do
specify { (Time.now + 1).should == Time.at(1303656390 + 1)}
specify { (Time.now + Unit("10 min")).should == Time.at(1303656390 + 600)}
Expand All @@ -36,4 +36,4 @@
specify { (Time.now - Unit("150 years")).should == Time.parse("1861-04-24 09:46:30 -0500")}
end

end
end

0 comments on commit e10cd0f

Please sign in to comment.