Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug? Looks like Rails internal time calculation DSL gets fucked up!? #11

Open
kristianmandrup opened this issue Mar 29, 2013 · 2 comments

Comments

@kristianmandrup
Copy link

I have written the timespan gem. After including time-lordweird things started to happen.

kristianmandrup/timespan#2

Then I wrote this test:

require 'spec_helper'

# To test and make sure that none of the included gems or any core extensions of this gem fuck up the 
# normal date calculation/comparison etc functionality of Ruby and Rails ;)

describe 'Ensure system Time calculations still operate as the should!' do
  it 'should add Time + Time normally' do
    expect(1.days + 3.days).to eq 4.days
  end

  it 'should add Date + Time normally' do
    expect(Date.today + 3.days).to eq 3.days.from_now.to_date
  end
end

Removed time-lord, and then the tests passed again. You should look into this ;)

@krainboltgreene
Copy link
Owner

Could you gist in the failure message?

Although I'm not surprised. Time-lord handles time math a lot differently
than Rails but has the same interfaces. Including time-lord in your rails
application will overrwrite the ActiveSupport::TimeHelpers and use the new
time math.

The best I can do is make sure all interfaces are covered so you're
completely using new time-lord stuff.

Alternatively you can require: false in your Gemfile and only require parts
of time-lord.

On Fri, Mar 29, 2013 at 5:06 AM, Kristian Mandrup
[email protected]:

I have written the timespan gem. After including time-lordweird things
started to happen.

kristianmandrup/timespan#2kristianmandrup/timespan#2

Then I wrote this test:

require 'spec_helper'

To test and make sure that none of the included gems or any core extensions of this gem fuck up the # normal date calculation/comparison etc functionality of Ruby and Rails ;)

describe 'Ensure system Time calculations still operate as the should!' do
it 'should add Time + Time normally' do
expect(1.days + 3.days).to eq 4.days
end

it 'should add Date + Time normally' do
expect(Date.today + 3.days).to eq 3.days.from_now.to_date
endend

Removed time-lord, and then the tests passed again. You should look into
this ;)


Reply to this email directly or view it on GitHubhttps://github.com//issues/11
.

Kurtis Rainbolt-Greene, Hacker
Software Developer
612 S. Flower St.
Los Angeles, CA, 90017

@kristianmandrup
Copy link
Author

Here are some...

require 'spec_helper'

# without this, the tests below pass just fine
require 'time-lord'

# To test and make sure that none of the included gems or any core extensions of this gem fuck up the 
# normal date calculation/comparison etc functionality of Ruby and Rails ;)

describe 'Ensure system Time calculations still operate as the should!' do
  it 'should add Time + Time normally' do
    expect(1.days + 3.days).to eq 4.days
  end

  it 'should add Date + Time normally' do
    expect(Date.today + 3.days).to eq 3.days.from_now.to_date
  end
end

Removing the .to_date

  it 'should add Date + Time normally' do
    expect(Date.today + 3.days).to eq 3.days.from_now
  end
Ensure system Time calculations still operate as the should! should add Date + Time normally
     Failure/Error: expect(Date.today + 3.days).to eq 3.days.from_now

       expected: #<TimeLord::Period:0x007f91b08890c0 @beginning=2013-04-01 20:14:08 +0200, @ending=2013-03-29 19:14:08 +0100>
            got: Tue, 28 Nov 2722

       (compared using ==)

       Diff:
       @@ -1,4 +1,2 @@
       -#<TimeLord::Period:0x007f91b08890c0
       - @beginning=2013-04-01 20:14:08 +0200,
       - @ending=2013-03-29 19:14:08 +0100>
       +Tue, 28 Nov 2722

Oops! Calculation about 710 years wrong!!!

I think the problem is either the + or the compare overrides? include Comparable ?

Would be nice if you could at least make these two scenarios pass ;)

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants