Sha256: 54f0481a5a8b12eec333c8c316030a3b165024c838d8b3a836cfc71c15ebc8d7

Contents?: true

Size: 1.6 KB

Versions: 52

Compression:

Stored size: 1.6 KB

Contents

require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/methods', __FILE__)

describe "Time.at" do
  platform_is_not :windows do
    ruby_version_is '' ... '1.9' do
      it "converts to time object" do
        with_timezone "GMT" do
          # the #chomp calls are necessary because of RSpec
          t = Time.at(1184027924)
          t.inspect.chomp.should == "Tue Jul 10 00:38:44 +0000 2007"
        end
      end
    end

    ruby_version_is '1.9' do
      it "converts to time object" do
        with_timezone "GMT" do
          # the #chomp calls are necessary because of RSpec
          t = Time.at(1184027924)
          t.inspect.chomp.should == "2007-07-10 00:38:44 +0000"
        end
      end
    end
  end

  it "creates a new time object with the value given by time" do
    t = Time.now
    Time.at(t).inspect.should == t.inspect
  end

  it "creates a dup time object with the value given by time" do
    t1 = Time.new
    t2 = Time.at(t1)
    t1.object_id.should_not == t2.object_id
  end

  it "is able to create a time object with a float" do
    t = Time.at(10.5)
    t.usec.should == 500000.0
    t.should_not == Time.at(10)
  end

  it "is able to create a time object with a microseconds" do
    t = Time.at(10, 500000)
    t.usec.should == 500000.0
    t.should_not == Time.at(10)
  end

  it "returns a subclass instance on a Time subclass" do
    c = Class.new(Time)
    t = c.at(0)
    t.should be_kind_of(c)
  end

  it "returns a subclass instance when passed a Time object" do
    c = Class.new(Time)
    t = c.at(Time.now)
    t.should be_kind_of(c)
  end

end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
rhodes-3.2.2 spec/framework_spec/app/spec/core/time/at_spec.rb
rhodes-3.2.2.beta spec/framework_spec/app/spec/core/time/at_spec.rb
rhodes-3.2.1 spec/framework_spec/app/spec/core/time/at_spec.rb
rhodes-3.2.0 spec/framework_spec/app/spec/core/time/at_spec.rb
rhodes-3.2.0.beta.9 spec/framework_spec/app/spec/core/time/at_spec.rb
rhodes-3.2.0.beta.8 spec/framework_spec/app/spec/core/time/at_spec.rb
rhodes-3.2.0.beta.7 spec/framework_spec/app/spec/core/time/at_spec.rb
rhodes-3.2.0.beta.6 spec/framework_spec/app/spec/core/time/at_spec.rb
rhodes-3.2.0.beta.5 spec/framework_spec/app/spec/core/time/at_spec.rb
rhodes-3.2.0.beta.4 spec/framework_spec/app/spec/core/time/at_spec.rb
rhodes-3.2.0.beta.2 spec/framework_spec/app/spec/core/time/at_spec.rb
rhodes-3.2.0.beta.1 spec/framework_spec/app/spec/core/time/at_spec.rb