Post

RSpec/MultipleExpectationsを回避

解決

aggregate_failures を使用する

it "正常動作する" do subject aggregate_failures "最後まで通過" do expect(job_instance).to have_received(:hoge1) expect(job_instance).to have_received(:hoge2).at_least(1).times end end

実用的な新機能が盛りだくさん!RSpec 3.3 完全ガイド - Qiita

事象

it "正常動作する" do subject expect(job_instance).to have_received(:hoge1) expect(job_instance).to have_received(:hoge2).at_least(1).times end

をrubocopで検査すると下記のエラーが発生する

spec/jobs/hoge.rb:35:5: C: RSpec/MultipleExpectations: Example has too many expectations [2/1]. it "正常動作する" do ^^^^^^^^^^^

Class: RuboCop::Cop::RSpec::EmptyExampleGroup — Documentation for rubocop-rspec (1.7.0)

This post is licensed under CC BY 4.0 by the author.