LoginSignup
0
0

More than 1 year has passed since last update.

warning: instance variable @parameterized_pending_cases not initialize

Last updated at Posted at 2016-09-26

rspec-parameterized specがわかりやすく書けて、とっても大好きです。

が、、、前々からちょっと気になっていたんだけど目をつぶっていた点が1つ。。。

warning: instance variable @parameterized_pending_cases not initialize

が頻発する!!!

というか Rails のプロジェクトでは出ないんだけど、最近書いているRailsじゃないspecでは頻発する。。。何が違うんだろう。。。

重い腰を上げてみたところ

これか~!!!!
最近 warngin を出すかどうかの設定が .rspec から spec/spec_helper.rb に移ったのかぁ。
そうかそうか、Railsの spec/spec_helper.rb はずっと前に生成したやつで、最近書いてるのは最近生成したから出るようになっちゃったのかぁ

と、思ったんですが。。。

committed on 3 Jun 2014 。。。 はい???

いやいや、Warningが出ないRailsのspec_helper.rbもそこまで古くはないっすよ。。。
と、思って双方のspec_helper.rbを見くらべてみると

Railsの方には config.warnings = true の記述はないが、Railsじゃない方は確かに config.warnings = true と書いてある。。。

へ? 何で??? と思って git の履歴を辿ってみたが、その部分は誰も手を加えていない。。。
怪奇現象!!!

と、いう事で双方のdiffをとってみると。。。

-# This file was generated by the `rails generate rspec:install` command. Conventionally, all
+# This file was generated by the `rspec --init` command. Conventionally, all

まじか!!! rails generate rspec:installrspec --init だと違うもんが出てくるんかい。

Railsさんは気を効かせて

 # This setting enables warnings. It's recommended, but in some cases may
 # be too noisy due to issues in dependencies.
 config.warnings = true

を削ってくれていたのね。ありがとうRails。ありがとう。。。。
ありがとう。。。
あり。。。・゚・(ノД`)・゚・。

後日談

Ruby 3.0 では https://github.com/ruby/ruby/blob/v3_0_0/NEWS.md の一番下に

Accessing an uninitialized instance variable no longer emits a warning in verbose mode. [Feature #17055]

と書いてある通り Ruby として Wraning が出ないようになりました。めでたしめでたし。

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