LoginSignup
3
3

More than 5 years have passed since last update.

shoulda-matchers 2.8.0で undefined method `validate_presence_of'などと出たので。

Posted at
  • Rails 4.2.0
  • Rspec 3.2.2
  • shoulda-matchers 2.8.0
it { should validate_presence_of(:hoge) }
it { should validate_uniqueness_of(:hage) }

とかでundefined methodだと怒られました。調べてみると・・・

[https://github.com/thoughtbot/shoulda/issues/203:embed:cite]

ちょっとバージョンが古いのですが、その他のコメントを見ると

[https://github.com/thoughtbot/shoulda/issues/203#issuecomment-73694540]

Having the same error with rails '4.2.0' & shoulda-matchers 2.8.0 & rspec-rails 3.1.0

新しくても問題は起こっているようです。

spec_helperrequire 'shoulda/matcherを追加しろとか(ハイフンでなくてスラッシュであるのがポイントかな?)

いろいろあるんですが、結局

[https://github.com/thoughtbot/shoulda/issues/203#issuecomment-42126779]

It seems that reverting shoulda-matcher back to version 2.5.0 fix this.

これがめんどくさくなくていいかな、と思いバージョンを2.5.0に指定して入れ直しましたよと・・・。

Gemfile

.
.
group :test do
  gem 'capybara'
  gem 'faker'
  gem 'shoulda-matchers', '2.5.0'
end
3
3
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
3
3