Testing (RSpec) with Devise's confirmable module

后端 未结 7 1091
不思量自难忘°
不思量自难忘° 2020-12-24 13:06

It\'s my understanding that Rails\' testing environment is torn down and rebuilt before each test...so how do I test a controller that requires that a user be logged in and

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-24 13:52

    If you are using factory_girl to generate your models, you can use after_create to confirm each new user.

    Factory.define :confirmed_user, :parent => :user do |f|
      f.after_create { |user| user.confirm! }
    end
    

提交回复
热议问题