Ruby on rails 在我的测试中,如果一个值大于零,我如何断言?

Ruby on rails 在我的测试中,如果一个值大于零,我如何断言?,ruby-on-rails,postgresql,ruby-on-rails-5,assert,minitest,Ruby On Rails,Postgresql,Ruby On Rails 5,Assert,Minitest,使用Rails 5.1、PostGres 9.4和minitest。我的PostGres表中有这个列 total_paid | double precision | 我的test/fixtures/workers.yml文件中有这个 one: username: MyString password: MyString enabled: true total_paid: 0.00001 但是在我的测试中,虽然我可以看到值是通过我的“put

使用Rails 5.1、PostGres 9.4和minitest。我的PostGres表中有这个列

 total_paid         | double precision            |
我的test/fixtures/workers.yml文件中有这个

one:
  username: MyString
  password: MyString
  enabled: true
  total_paid: 0.00001
但是在我的测试中,虽然我可以看到值是通过我的“puts”语句设置的,但最后一个断言失败了

  test "Test total paid" do
    worker = workers(:one)
    puts "#{worker.inspect}"
    assert_operator worker.total_paid, :>, 0, "A pre-condition of this test is that the stratum worker's total paid must be greater than zero."
它失败了

    Failure:
WorkerTest#test_Test_total_paid [/Users/satishp/Documents/workspace/cmine/test/models/worker_test.rb:14]:
Failed to return a non-zero value for total paid..
Expected NaN to be > 0.

工人总工资属性的数据类型是什么?您可以添加您的db/schema.rb吗?精度可能会给您带来问题。@SebastianPalma,根据我的第一行,PostGres列的数据类型是“双精度”。这是PostGres的“表示”,但Rails以不同的方式处理模型属性的数据类型。我在问这个问题,试图复制你的错误。哦,我误解了。在我的db/schema.rb文件中,该列被定义为“t.float”total_paid。这是您要问的吗?