LoginSignup
48
39

More than 5 years have passed since last update.

RSpecで普段は実行したくないテストをスキップする方法

Posted at

例えばツイートする機能のテストなど、stub化しちゃうとそもそも意味がなくなるけど、かといって毎回実行されるのがいやなテストをスキップする方法

specヘルパーに以下を追記。

spec/spec_helper.rb
RSpec.configure do |c|
  c.filter_run_excluding :skip => true
end

スキップしたいテストに :skip => true を追加。

spec/hoge_spec.rb
describe Hoge do
  it 'test', :skip => true do
    hoge.should eq(fuga)
  end
end

もしも普段スキップしているテストを実行した場合は--tagオプションを指定して実行する

rspec spec --tag skip

# => include {:skip=>true}
# => exclude {:exclude=>true}
48
39
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
48
39