Railsでコントローラのテストを書くときに、こういうコードをrspecで書きたいと思いました。
@book = Book.find_by_info(set_information).first
こういうふうに書くらしい。
allow(Book).to receive_message_chain(:find_by_info, :first){ book }
参考URL
Relish
Go to list of users who liked
Share on X(Twitter)
Share on Facebook
More than 5 years have passed since last update.
Railsでコントローラのテストを書くときに、こういうコードをrspecで書きたいと思いました。
@book = Book.find_by_info(set_information).first
こういうふうに書くらしい。
allow(Book).to receive_message_chain(:find_by_info, :first){ book }
参考URL
Relish
Register as a new user and use Qiita more conveniently
Go to list of users who liked