RailsのテストコードをRspecを用いて記述しています。
あるdeviseが定義されたモデルの1つのメソッドをテストしたいのですが、そのメソッド内にある条件下でconfirmed_atをnilにする
処理があり、その部分がnilにきちんとなるかどうかをテストをしたいと考えています。
しかし、specを記述してみると下記のエラーが発生してしました。
Failure/Error: = link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) ActionView::Template::Error: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true # ./app/views/devise/mailer/confirmation_instructions.html.slim:8:in `_app_views_devise_mailer_confirmation_instructions_html_slim__3450011377764834083_70300448161300' # ./spec/models/staff_spec.rb:230:in `block (3 levels) in <top (required)>' # ------------------ # --- Caused by: --- # ArgumentError: # Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true # ./app/views/devise/mailer/confirmation_instructions.html.slim:8:in `_app_views_devise_mailer_confirmation_instructions_html_slim__3450011377764834083_70300448161300'
###該当のソースコード
ruby
1it 'change confirmed_at from anytime to nil' do 2 staff = build(:staff, 3 state: [:in_active, :in_ban].sample 4 ) 5 staff.to_registed_preliminary 6 expect(staff.confirmed_at).to be_nil 7 end
deviseのメールを飛ばす処理をスキップするためにFactoryGirlにはconfirmed_atにTime.zone.nowと現在の日時を設定するようにしているのですが、これ以外でdeviseの処理をスキップする方法がありましたら、ご教授いただきたく質問させていただきました。
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。