1

RSpec テスト スイートで Spork と Guard を使用しています。私は遅いテストを実行から除外しています:

RSpec.configure do |config|
  ...
  config.filter_run_excluding slow: true
  ...
end

次に、必要に応じて、別のシェルで次のようにスロー テストを実行します。rspec . --tag slow

Guard がテストを自動実行しているのと同じシェルでスロー タグを実行するためのショートカットがあるかどうか疑問に思っています。

コンソール>プロンプトはありますか?ドキュメントを見た後、> と入力すると. rspec . --tag slow機能することがわかりました...しかし、それは別のシェルに切り替えるよりも少し冗長です。これはかなり一般的な要求のようです。アイデア?

4

2 に答える 2

6

グループを定義し、各グループに異なる 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 を起動すると、デフォルトで fast 仕様になります。

$ 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)>

Enter キーを押すと、すべての高速スペックが実行されます。

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}

スコープを遅い仕様に切り替えて、Enter キーを押してすべてを実行することもできます。

[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}

それが役立つことを願っています!

于 2013-08-29T20:04:30.923 に答える
1

このコードは、監視しているファイル内で「高速」とタグ付けされたすべてのテストを実行します。

guard 'rspec', :version => 2, :cli => "--tag ~fast" do
# code for watching
end

必要なテストのみを実行するには、cli オプションを使用する必要があります。

于 2013-08-29T07:54:36.463 に答える