测试 RSpec 如何只运行一个 it

kingwkb · 2013年12月30日 · 最后由 dw512 回复于 2015年12月17日 · 3241 次阅读

一个文件里面有很多个 it,现在一个发现错误,如何只运行这一个 it,来调试什么的

-l参数 后面加行数

rspec spec/models/user_spec.rb:

TextMate + RSpec.bundle,可以在 it 那段按 Shift + Command + R 来执行

#5 楼 @huacnlee 我用 sublime text 3 好像没有这个功能吗

rspec spec/xx_spec.rb:number

最近做 Ruby on Rails Tutorial 的教程,裡面有這樣的範例:

$ rspec spec/requests/user_pages_spec.rb -e "signup page"

書中的說明: The -e here arranges to run just the examples whose description strings match "signup page". Note in particular that this is not the substring "signup", which would run all the test

另外找到 Stackoverflow 上也有一篇:http://stackoverflow.com/questions/6518425/test-only-one-it-or-describe-with-rspec

文件后面加上冒号,再加上 it 的行号就可以了 比如我的: rspec spec/features/dw_spec.rb:12 -f doc

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