diff options
Diffstat (limited to 'spec/ruby/library/datetime/now_spec.rb')
| -rw-r--r-- | spec/ruby/library/datetime/now_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/ruby/library/datetime/now_spec.rb b/spec/ruby/library/datetime/now_spec.rb new file mode 100644 index 0000000000..5c0411c2be --- /dev/null +++ b/spec/ruby/library/datetime/now_spec.rb @@ -0,0 +1,25 @@ +require_relative '../../spec_helper' +require 'date' + +describe "DateTime.now" do + it "creates an instance of DateTime" do + DateTime.now.should.instance_of?(DateTime) + end + + it "sets the current date" do + (DateTime.now - Date.today).to_f.should be_close(0.0, TIME_TOLERANCE) + end + + it "sets the current time" do + dt = DateTime.now + now = Time.now + (dt.to_time - now).should be_close(0.0, TIME_TOLERANCE) + end + + it "grabs the local timezone" do + with_timezone("PDT", -8) do + dt = DateTime.now + dt.zone.should == "-08:00" + end + end +end |
