the industrial

ブログと言うより自分のためのメモ以外の何モノでもないです。でも読んでくださってありがとうございます。

RSpecで特定のテストケースだけを実行する方法

指定したパスのexampleを実行する。

rspec spec/
rspec spec/controller

ファイルを指定すれば、そのファイル内のexampleを実行してくれる。

rspec spec/services/hoge_spec.rb

さらに特定のexampleのみ実行したい場合、configに書きを追記。

RSpec.configure do |config|
  ・・・
  config.filter_run_when_matching :focus
  ・・・
end
spec/spec_helper.rb

そして、exampleに :focus => true を指定する。( :focus => true を指定したexampleのみ実行してくれる)

it "[CASE-1]hogehoge", :forcus => true do
end

Class: RSpec::Core::Configuration — Documentation by YARD 0.9.16