コード日進月歩

しんくうの技術的な小話、メモ、つれづれ、など

RSpecのbeforeとafterのパラメータ、each/allはexample/contextのエイリアス

あ、そうなの?っていう感じだったのでさらりなメモ

環境

$ bundle exec rspec -v
RSpec 3.8
  - rspec-core 3.8.0
  - rspec-expectations 3.8.2
  - rspec-mocks 3.8.0
  - rspec-rails 3.8.1
  - rspec-support 3.8.0

出典

Note: the :example and :context scopes are also available as :each and :all, respectively. Use whichever you prefer. - `before` and `after` hooks - Hooks - RSpec Core - RSpec - Relish

スーパー意訳すると以下

:example と :context は :each と :all のスコープです、お好きな方をお使いください。

調べてみての補足

どちらかと言うと :all などが混同の種なので :example を使ってほしいという流れの様子

関連リンク

RSpec 3の重要な変更 - 有頂天Ruby