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

Add tests for Time.at with BigDecimal input #187

Merged
merged 1 commit into from
Feb 16, 2016
Merged

Add tests for Time.at with BigDecimal input #187

merged 1 commit into from
Feb 16, 2016

Conversation

alex88
Copy link
Contributor

@alex88 alex88 commented Feb 15, 2016

I've added a test that checks if Time.at rounds the input when a float BigDecimal is passed.

Probably the place of the test is wrong so let me know where it should be moved and I'll be happy to do that.

This relates to jruby/jruby#3616

@eregon
Copy link
Member

eregon commented Feb 15, 2016

Time.at is part of the core library, so it should be in https://github.com/ruby/spec/blob/master/core/time/at_spec.rb.
But indeed this spec example requires the bigdecimal stdlib.

Therefore I would say move it to core and move the require 'bigdecimal' in the example so only that one would fail if bigdecimal was not available.
(An alternative would be to do this with mocks to check that to_r is tried before to_int but it seems tricky and would still leave plenty of room for implementations to fail with a real BigDecimal, so I like this more realistic test.)

@alex88
Copy link
Contributor Author

alex88 commented Feb 15, 2016

Let me know if that works for you, however, wouldn't it be better to actually check if require fails and in that case mark the test as skipped? Since in that case it's not a real failure (even if stdlib should be always available)

@@ -135,4 +135,11 @@
lambda { Time.at(Time.now, 500000) }.should raise_error(TypeError)
end
end

describe "passed BigDecimal" do
require 'bigdecimal'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The require should be in the it block.

@eregon
Copy link
Member

eregon commented Feb 16, 2016

Let me know if that works for you, however, wouldn't it be better to actually check if require fails and in that case mark the test as skipped? Since in that case it's not a real failure (even if stdlib should be always available)

There is a system of tags allowing to skip one example easily so it's not a problem in practice AFAIK.

@alex88
Copy link
Contributor Author

alex88 commented Feb 16, 2016

Done, let me know if you wanted also the describe inside the Numeric examples or just the it with something like doesn't round BigDecimal

eregon added a commit that referenced this pull request Feb 16, 2016
Add tests for Time.at with BigDecimal input
@eregon eregon merged commit e5db1f0 into ruby:master Feb 16, 2016
@eregon
Copy link
Member

eregon commented Feb 16, 2016

It's good as-is, merged, thank you for your contribution! 😃

@alex88 alex88 deleted the patch-1 branch February 16, 2016 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants