]> cat aescling's git repositories - mastodon.git/commitdiff
Use be_within instead of eq for a to_f test match (#6275)
authorMike Burns <mburns@thoughtbot.com>
Wed, 17 Jan 2018 11:45:09 +0000 (06:45 -0500)
committerEugen Rochko <eugen@zeonfederated.com>
Wed, 17 Jan 2018 11:45:09 +0000 (12:45 +0100)
Floating point values are notoriously hard to pin down, so use the
`be_within` matcher to verify the approximate value.

spec/services/precompute_feed_service_spec.rb

index d1ef6c1843ac392211d224b6d38fedc9df8f4c05..396a3c3fba4bee808479c757061146f871ba1c8c 100644 (file)
@@ -16,7 +16,7 @@ RSpec.describe PrecomputeFeedService do
 
       subject.call(account)
 
-      expect(Redis.current.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to eq status.id.to_f
+      expect(Redis.current.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to be_within(0.1).of(status.id.to_f)
     end
 
     it 'does not raise an error even if it could not find any status' do