Sha256: d88fbde96c0f420baa81a7266097a19982d68263b53788a1b865cd23cee8ff35

Contents?: true

Size: 777 Bytes

Versions: 21

Compression:

Stored size: 777 Bytes

Contents

require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
require 'json'

describe Time, "#to_json" do

  before do
    @expected = "\"2008-03-28T22:54:20Z\""
  end

  it "should transform itself into a ISO 8601 compatible string" do
    Time.utc(2008, 3, 28, 22, 54, 20).to_json.should == @expected
    Time.xmlschema("2008-03-28T22:54:20Z").to_json.should == @expected
    Time.xmlschema("2008-03-28T17:54:20-05:00").to_json.should == @expected
  end
end

describe Time, "#to_time" do
  it "should return a copy of its self" do
    time = Time.now
    time.to_time.should == time
  end
end

describe Time, "#to_datetime" do
  it "should return an equivalent DateTime" do
    time = Time.now
    time.to_datetime.should == DateTime.parse(time.to_s)
  end
end

Version data entries

21 entries across 20 versions & 5 rubygems

Version Path
sundbp-extlib-0.9.14 spec/time_spec.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/extlib-0.9.14/spec/time_spec.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.8/gems/extlib-0.9.14/spec/time_spec.rb
middleman-0.12.2 lib/middleman/vendor/gems/gems/extlib-0.9.14/spec/time_spec.rb
middleman-0.12.1 lib/middleman/vendor/gems/gems/extlib-0.9.14/spec/time_spec.rb
extlib-0.9.14 spec/time_spec.rb
ginst-2009.12.8 vendor/gems/extlib-0.9.13/spec/time_spec.rb
middleman-0.12.0.pre3 lib/middleman/vendor/gems/gems/extlib-0.9.13/spec/time_spec.rb
middleman-0.12.0.pre2 lib/middleman/vendor/gems/gems/extlib-0.9.13/spec/time_spec.rb
middleman-0.12.0.pre lib/middleman/vendor/gems/gems/extlib-0.9.13/spec/time_spec.rb
ginst-2009.11.24 vendor/gems/extlib-0.9.13/spec/time_spec.rb
ginst-2009.11.23 vendor/gems/extlib-0.9.13/spec/time_spec.rb
rango-0.0.6 vendor/extlib/spec/time_spec.rb
rango-0.1.pre vendor/extlib/spec/time_spec.rb
middleman-0.10.17 vendor/gems/gems/extlib-0.9.13/spec/time_spec.rb
middleman-0.10.16 vendor/gems/gems/extlib-0.9.13/spec/time_spec.rb
middleman-0.10.15 vendor/gems/gems/extlib-0.9.13/spec/time_spec.rb
middleman-0.10.14 vendor/gems/gems/extlib-0.9.13/spec/time_spec.rb
ginst-2.0.1 vendor/gems/extlib-0.9.13/spec/time_spec.rb
ginst-2.0.0 vendor/gems/extlib-0.9.13/spec/time_spec.rb