LoginSignup
1
0

More than 5 years have passed since last update.

action_args を rspec3 で使う時にエラーが出たら、action_args_controller_spec.rb のカスタムテンプレートで回避できる

Posted at

Ruby - Rails開発で有用な便利Gem一覧:2014年版 - Qiita

で紹介されていた、action_args

Rspec3 環境では動かないようだ。下記のエラーが出る

(erb):8:in `template': undefined local variable or method `example_valid_attributes' for #<Rspec::Generators::ScaffoldGenerator:0x007fcb128f0c98> (NameError)

template の中で rspec3 では 削除されたメソッドを使っているようだ。

rspec-rails 2.14 にはあったが、rspec-rails 3.1.0 には無かった(grep 調べ)。

template だけなので、上書きすれば良いと思い、下記のファイルを用意したが、使われなかった。

lib/templates/rspec/scaffold/controller_spec.rb

aciton_args からは action_args_controller_spec.rb が呼ばれているので、
そちらを定義することで上書きできた。

lib/templates/rspec/scaffold/action_args_controller_spec.rb

これで rspec3 でも使える。

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