LoginSignup
0
0

More than 1 year has passed since last update.

【解決済】Rspec WrongScopeErrorが発生

Posted at

Rspecでテストを走らせた際に発生した問題について、備忘録として投稿します。

発生した問題

ターミナル
Failure/Error:
       raise WrongScopeError,
             "`#{name}` is not available from within an example (e.g. an " \
             "`it` block) or from constructs that run in the scope of an " \
             "example (e.g. `before`, `let`, etc). It is only available " \
             "on an example group (e.g. a `describe` or `context` block)."

       `name` is not available from within an example (e.g. an `it` block) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc). It is only available on an example group (e.g. a `describe` or `context` block)

nameに心当たりがないので、Rspecの設定に問題があると推測。

原因

上記Issueに原因がありましたが、
rspec-rails3.xだとバージョンが低い
ことが理由のようです。

対策

Gemfile
gem "rspec-rails", "~> 4.0.2"

この設定で無事、テストが走りました!

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