Ruby How to write custom expectations with RSpec

greyblake · 2012年12月14日 · 最后由 josh_sulin 回复于 2014年06月22日 · 2360 次阅读

Quite often we write custom matchers. Here is an examle how to write custom expectation (which works with "expect" RSpec DSL): http://greyblake.com/blog/2012/12/14/custom-expectations-with-rspec/

The answer is 0 for me. I'm using minitest. :-)

It's said that the minitest will be included as the default test framework in Rails 4. A single command would tell me if the migration from my rails 3 projects to rails4 is successful or not.

rake test

除了 custom expectations 外,我们经常会写一下 custom matcher, 比如我们会有这样的需求,每次跑 Rspec 来检测代理里面有没有特定的字符,自定义输出详细的错误。

推荐学习资料:https://www.relishapp.com/rspec/rspec-expectations/v/2-3/docs/custom-matchers

需要 登录 后方可回复, 如果你还没有账号请 注册新账号