I have a spec for a method that returns a timestamp of an ActiveRecord object.
The spec passes locally, but whenever it is run on CircleCI, there is a slight mismatch between the expected and the actual.
The spec looks something like this:
describe '#my_method' do
it 'returns created_at' do
object = FactoryGirl.create(:something)
expect(foo.bar(object)).to eq object.created_at
end
end
While it passes locally, on CircleCI, I continually get similar error messages.
Here are examples:
(1)
expected: 2015-05-09 10:42:59.752192641 +0000
got: 2015-05-09 10:42:59.752192000 +0000
(2)
expected: 2015-05-08 10:16:36.777541226 +0000
got: 2015-05-08 10:16:36.777541000 +0000
From the error, I suspect that CircleCI is rounding up the timestamp value, but I do not have enough information. Any suggestions?
You can also define the precision of your time columns in your schema, this way ActiveRecord will take care of precision truncating at type cast.
See https://github.com/rails/rails/blob/39de1156970d52b441ff944862ebe16a47de784f/activemodel/lib/active_model/type/date_time.rb#L18
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With