ファイル内で単一の仕様を実行するには、さまざまな方法があることを知っています。つまり、仕様がタグ付けされていない限り、これは魅力のように機能します (つまり、非常に遅いため..)
rspec spec/models/event_spec.rb:311
これにより、遅いとタグ付けされたすべての仕様が実行されます...
rspec -t slow spec/models/event_spec.rb
...しかし、完了するまでに約 2 年かかります。
低速スペックの実行を制限しようとする次の試みはすべて、指定されたファイルからタグ付けされていないすべてのスペックを実行することになります。
rspec -t slow -e "A describe block tagged as slow" spec/models/event_spec.rb
rspec -e "A describe block tagged as slow" spec/models/event_spec.rb
rspec -t slow spec/models/event_spec.rb:378 #the line number of the describe block
rspec spec/models/event_spec.rb:378 #the line number of the describe block
rspec -e "A single slow spec" -t slow spec/models/event_spec.rb
rspec -t slow -e "A single slow spec" -t slow spec/models/event_spec.rb
rspec -t slow spec/models/event_spec.rb:466 #a line number of a single slow spec
rspec spec/models/event_spec.rb:466 #a line number of a single slow spec
#It seems the order of the file/path and the options makes no difference..
rspec spec/models/event_spec.rb -t slow -e "A describe block tagged as slow"
rspec spec/models/event_spec.rb -e "A describe block tagged as slow"
rspec spec/models/event_spec.rb:378 -t slow #the line number of the describe block
rspec spec/models/event_spec.rb -e "A single slow spec" -t slow
rspec spec/models/event_spec.rb -t slow -e "A single slow spec"
rspec spec/models/event_spec.rb#466 -t slow #a line number of a single slow spec
これは不可能ですか、それとも何が間違っていますか?
PS Rspec バージョン 2.10.1
アップデート
spec_helper では、Rspec がデフォルトで遅いテストを実行しないように (明らかに) 構成されており、すべてがフィルター処理された場合はすべてのテストを実行するように構成されていることは言及しませんでした。(TBH、これがデフォルトの動作だと思っていたので、最初は言及しませんでした)
RSpec.configure do |config|
config.mock_with(:rspec)
config.expect_with(:rspec)
config.filter_run_excluding(:slow => true)
config.run_all_when_everything_filtered = true
end
そして、これは動作をテストするのに十分なはずです:
# -*- encoding : utf-8 -*-
require 'spec_helper'
describe 'Demonstrating tagging issue' do
describe "some tests that take a very long time to run", slow: true do
it "slow test 1" do
puts "it should be slow"
end
it "shlow test 2" do
puts "it should be slow too"
end
end
it "normal test" do
puts "it should be fast"
end
end
したがって、実行する正確なテストを行番号またはサンプル名で指定しようとすると、遅い仕様を無視するという設定済みのデフォルトの動作を強制的に変更しようとするすべての努力が無視されるようです..したがって、すべてがフィルタリングされ、その後、すべてを実行します。
更新 2
私が達成しようとしていることをさらに特定するために。複数の例のタグが遅いファイルがあるファイルがあります。これらのタグには触れたくないので、これらの遅い例の 1 つを実行したいと思います。私のspec_helper.rbからこの設定をコメントアウトすれば、これは簡単なことです
config.filter_run_excluding(:slow => true)
次に、行番号の指定、-e cmd 行オプション、使用したいフォーカス タグのいずれかの方法が機能します。ただし、構成をいじる必要なく、それを達成できると期待していました。今のところ、これは実際には不可能である可能性が最も高いと確信しています..