Test::Unit Rails - How to assert one number is greater than another one?

前端 未结 3 871
[愿得一人]
[愿得一人] 2021-02-06 21:34

I am writing my first unit tests with Test::Unit and I have reached a point where I need to compare two numbers. Much to my surprise, I have discovered that none of the followin

3条回答
  •  自闭症患者
    2021-02-06 21:40

    Rather than provide a bunch of different assertions as you suggest, Test::Unit provides the method assert_operator, used like this:

    assert_operator x, :>, y
    assert_operator x, :>=, y
    etc. 
    

提交回复
热议问题