Ruby How to write custom expectations with RSpec

greyblake · December 14, 2012 · Last by josh_sulin replied at June 22, 2014 · 2362 hits

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

You need to Sign in before reply, if you don't have an account, please Sign up first.