LoginSignup
5
5

More than 5 years have passed since last update.

Paperclipのデータ保存/削除処理をstub化する方法

Last updated at Posted at 2012-11-01

PaperClipを使ってデータを保存するモデルを作る場合、create等データを保存/削除する処理をした場合、テストの度にファイルが上がってしまう。そこで保存/削除処理をstub化してこれを回避するための方法
save_attached_files,prepare_for_destroy,destroy_attached_filesをstub化すれば良い。

Model.any_instance.stub(:save_attached_files).and_return(true)
Model.any_instance.stub(:prepare_for_destroy).and_return(true)
Model.any_instance.stub(:destroy_attached_files).and_return(true)
5
5
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
5
5