commit
c69b75f88b
2 changed files with 5 additions and 11 deletions
|
@ -33,13 +33,14 @@ Will return something like: 1311972653
|
||||||
|
|
||||||
ENV['TZ'] = time_zone
|
ENV['TZ'] = time_zone
|
||||||
|
|
||||||
time = local_time.localtime
|
result = local_time.localtime.strftime('%s')
|
||||||
|
|
||||||
ENV['TZ'] = original_zone
|
ENV['TZ'] = original_zone
|
||||||
|
else
|
||||||
|
result = time.localtime.strftime('%s')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Calling Time#to_i on a receiver changes it. Trust me I am the Doctor.
|
# Calling Time#to_i on a receiver changes it. Trust me I am the Doctor.
|
||||||
result = time.strftime('%s')
|
|
||||||
result = result.to_i
|
result = result.to_i
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -7,7 +7,7 @@ describe 'time' do
|
||||||
context 'when running at a specific time' do
|
context 'when running at a specific time' do
|
||||||
before(:each) {
|
before(:each) {
|
||||||
# get a value before stubbing the function
|
# get a value before stubbing the function
|
||||||
test_time = Time.utc(2006, 10, 13, 8, 15, 11, '+01:00')
|
test_time = Time.utc(2006, 10, 13, 8, 15, 11)
|
||||||
Time.expects(:new).with().returns(test_time).once
|
Time.expects(:new).with().returns(test_time).once
|
||||||
}
|
}
|
||||||
it { is_expected.to run.with_params().and_return(1160727311) }
|
it { is_expected.to run.with_params().and_return(1160727311) }
|
||||||
|
@ -16,13 +16,6 @@ describe 'time' do
|
||||||
it { is_expected.to run.with_params({}).and_return(1160727311) }
|
it { is_expected.to run.with_params({}).and_return(1160727311) }
|
||||||
it { is_expected.to run.with_params('foo').and_return(1160727311) }
|
it { is_expected.to run.with_params('foo').and_return(1160727311) }
|
||||||
it { is_expected.to run.with_params('UTC').and_return(1160727311) }
|
it { is_expected.to run.with_params('UTC').and_return(1160727311) }
|
||||||
|
it { is_expected.to run.with_params('America/New_York').and_return(1160727311) }
|
||||||
context 'when running on modern rubies', :unless => RUBY_VERSION == '1.8.7' do
|
|
||||||
it { is_expected.to run.with_params('America/Los_Angeles').and_return(1160727311) }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when running on ruby 1.8.7, which garbles the TZ', :if => RUBY_VERSION == '1.8.7' do
|
|
||||||
it { is_expected.to run.with_params('America/Los_Angeles').and_return(1160702111) }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue