ハイパーニートプログラマーへの道

頑張ったり頑張らなかったり

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

it { should validate_presence_of(:hoge) }
it { should validate_uniqueness_of(:hage) }

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

github.com

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

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