您可以定义组并在每个组中具有不同的 rspec 配置。
将以下代码附加到以下内容/Guardfile
:
scope group: :fast
group :fast do
guard 'rspec', cli: '--tag ~slow' do
# code for watching
end
end
group :slow do
guard 'rspec', cli: '--tag slow' do
# code for watching
end
end
当您启动 Guard 时,它默认为快速规格:
$ guard
21:56:35 - INFO - Guard::RSpec is running
21:56:35 - INFO - Guard is now watching at '/Users/michi/testproject'
[1] {Fast} guard(main)>
按回车键将运行所有快速规格:
22:02:00 - INFO - Run Fast
22:02:00 - INFO - Running all specs
Run options: exclude {:slow=>true}
现在你可以通过按下来运行所有慢的slow
:
[2] {Fast} guard(main)> slow
22:02:50 - INFO - Run Slow
22:02:50 - INFO - Running all specs
Run options: include {:slow=>true}
您还可以将范围切换到慢速规格并按回车键运行它们:
[3] {Fast} guard(main)> scope slow
[4] {Slow} guard(main)>
22:03:30 - INFO - Run Slow
22:03:30 - INFO - Running all specs
Run options: include {:slow=>true}
希望有帮助!