在RSpec中:我可以像在xUnit风格的测试框架中那样,将消息附加到判断中吗?怎样
assert_equal value1, value2, 'something is wrong'
在RSpec中:我可以像在xUnit风格的测试框架中那样,将消息附加到判断中吗?怎样
assert_equal value1, value2, 'something is wrong'
对于RSpec 3+:
消息可以自定义为字符串或使用proc(判断引用).
expect(1).to eq(2), 'one is not two!'
自定义消息
对于较旧的RSpec版本
should
和should_not
采用第二个参数(message
),该参数覆盖匹配器的默认消息.
1.should be(2), 'one is not two!'
不过,默认消息通常非常有用.