LoginSignup
6
5

More than 1 year has passed since last update.

Rspec | subject にラムダを使う ( expect でブロックを使う場合の is_expected の書き方 )

Last updated at Posted at 2016-11-01

expect を ブロックで囲わなければいけない検証の場合。

it { expect { some_action }.to change { some_status } }

普通に subject / is_expected を書こうとすると落ちる

subject { some_action }
it { is_expected.to change { some_status } }

ラムダを使えば解決。

subject { -> { some_action } }
it { is_expected.to change { some_status } }

環境

  • rspec 3.4.0

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

6
5
0

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
6
5