LoginSignup
1

More than 5 years have passed since last update.

RSpec (shoulda-matchers) のensure_inclusion_in、ensure_length_ofがundefined methodになる際の解決方法

Last updated at Posted at 2017-05-02

バージョンアップによるメソッド名の変更

ensure_inclusion_in、ensure_length_ofから始まるメソッドはバージョンアップ時に名前が変更された。

★Version2系の時はensureで書くことができた

以下の様にテストコードを書くことができた。

test_spec.rb
it { should ensure_length_of(:comment).is_at_most(10000) }

★Version3系になるとensureがvalidateにリネームされている。

以下の様に書く必要がある。

test_spec.rb
it { should validate_length_of(:comment).is_at_most(10000) }

参考

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