How to attach message to rspec check?

后端 未结 3 2029
野的像风
野的像风 2021-02-01 13:41

In rspec: Can I attach a message to a check the same way as I would do in xUnit style test frameworks? How?

assert_equal value1, value2, \"something is wrong\"
<         


        
3条回答
  •  无人及你
    2021-02-01 13:58

    should and should_not take a second argument (message) that overrides the matcher’s default message.

    1.should be(2), 'one is not two!'
    

    The default messages are usually pretty useful though.

    update:

    for RSpec 3:

    expect(1).to eq(2), "one is not two!"
    

提交回复
热议问题