修改Rspec

时间:2015-07-27 15:41:34

标签: ruby rspec cucumber

我正在使用Ruby,Rspec和Cucumber来运行测试。我有这样的事情:

expect(@response.code).to eql(200)

当参数不是200时,将显示以下输出:

(compared using eql?)
(RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/accounts_steps.rb:159:in `/^I see an? '(accepted|created|ok)' (create|authorization|payment|confirmation) response$/' features/honduras/honduras-claro-bundle-postpay.feature:9:in 
Then I see an 'accepted' create response

我需要在此输出中添加一些相关信息,因此我想对其进行修改。如果可能的话,我想修改此异常的内置匹配器。有人可以帮忙吗?

非常感谢。

1 个答案:

答案 0 :(得分:0)

您可以使用customized message

expect(@response.code).to eql(200), "Expected to respond with 200 OK, but got #{@response.code}"

但是匹配器eql应该默认打印这样的消息:

   expected: 200
        got: 404
相关问题