在我的测试中,如何断言值是否大于零?

时间:2018-04-15 17:27:37

标签: 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

但是在我的测试中,虽然我可以看到通过我的“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.

0 个答案:

没有答案