3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

shoulda-matchersでマッチャを増やす

Posted at

shoulda-matchersをインストールするといろんなマッチャが使えるようになる。

GemFile
gem 'rspec-rails'
gem 'shoulda-matchers'

モデルに対するマッチャ。

should belong_to(:hoge)
should have_many(:fuga)
should validate_presence_of(:hogehoge)

コントローラに対するマッチャ。

should assign_to(:members).with(@members)

その他にもいろいろなのがある。
https://github.com/thoughtbot/shoulda

3
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?