Skip to content

Commit

Permalink
added specs to check Time.to_s format
Browse files Browse the repository at this point in the history
  • Loading branch information
calavera committed Nov 20, 2009
1 parent edabf0b commit c6e5097
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/time/inspect_spec.rb
@@ -1,2 +1,7 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/fixtures/methods'
require File.dirname(__FILE__) + '/shared/inspect'

describe "Time.inspect" do
it_behaves_like :inspect, :inspect
end
25 changes: 25 additions & 0 deletions core/time/shared/inspect.rb
@@ -0,0 +1,25 @@
describe :inspect, :shared => true do
ruby_version_is ""..."1.9" do
it "formats the time following the pattern 'EEE MMM dd HH:mm:ss Z yyyy'" do
with_timezone("PST", +1) do
Time.local("1", "15", "20", "1", "1", "2000", :ignored, :ignored, :ignored, :ignored).send(@method).should == "Sat Jan 01 20:15:01 +0100 2000"
end
end

it "formats the UTC time following the pattern 'EEE MMM dd HH:mm:ss UTC yyyy'" do
Time.utc("1", "15", "20", "1", "1", "2000", :ignored, :ignored, :ignored, :ignored).send(@method).should == "Sat Jan 01 20:15:01 UTC 2000"
end
end

ruby_version_is "1.9" do
it "formats the time following the pattern 'yyyy-MM-DD dd HH:mm:ss Z'" do
with_timezone("PST", +1) do
Time.local("1", "15", "20", "1", "1", "2000", :ignored, :ignored, :ignored, :ignored).send(@method).should == "2000-01-01 20:15:01 +0100"
end
end

it "formats the UTC time following the pattern 'yyyy-MM-DD HH:mm:ss UTC'" do
Time.utc("1", "15", "20", "1", "1", "2000", :ignored, :ignored, :ignored, :ignored).send(@method).should == "2000-01-01 20:15:01 UTC"
end
end
end
5 changes: 5 additions & 0 deletions core/time/to_s_spec.rb
@@ -1,2 +1,7 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/fixtures/methods'
require File.dirname(__FILE__) + '/shared/inspect'

describe "Time.to_s" do
it_behaves_like :inspect, :to_s
end

0 comments on commit c6e5097

Please sign in to comment.