49
39

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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}
49
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
49
39

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?