测试 RSpec 如何只运行一个 it

kingwkb · December 30, 2013 · Last by dw512 replied at December 17, 2015 · 3241 hits

一个文件里面有很多个 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

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