我认为有一种方法可以只运行具有给定标签的测试。有人知道吗?
发布于 2011-06-22 17:31:37
可以使用--example (or -e) option运行包含特定字符串的所有测试
rspec spec/models/user_spec.rb -e "User is admin"
我用得最多的就是那个。
发布于 2014-05-27 04:15:11
确保在您的spec_helper.rb
中配置了RSpec以关注focus
RSpec.configure do |config|
config.filter_run focus: true
config.run_all_when_everything_filtered = true
end
然后在您的规范中,添加focus: true
作为参数:
it 'can do so and so', focus: true do
# This is the only test that will run
end
您还可以通过将it
更改为fit
(或使用xit
排除测试)来关注测试,如下所示:
fit 'can do so and so' do
# This is the only test that will run
end
发布于 2011-02-22 02:25:12
或者,您可以传递行号:rspec spec/my_spec.rb:75
-行号可以指向单个规范或上下文/描述块(运行该块中的所有规范)
https://stackoverflow.com/questions/5069677
复制相似问题