LoginSignup
15
7

More than 5 years have passed since last update.

expected Exception but was not given a block

Posted at

expected Exception but was not given a block

Rspecにて自分が困ったエラーとその対処法のメモになります。

expect(~).to raise_error

というようなコードに対して、

Failure/Error: expect(~).to raise_error
expected Exception but was not given a block

ブロックが与えられていない、と怒られました。

この原因は「expect{}」と「expect()」の違いでした。

対象のexpect(~)をexpect{~}に修正したら通るようになりました。

それまでexpect(~).to eq()という形で使うことが続いていたので、
うっかり勘違いしていました。

この違いの詳しい情報に関しては下記URLが大変参考になります。

参考URL

15
7
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
15
7