3
0

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.

railsのtrailing_slash: trueがテストの時だけ効かない

Posted at

起きたこと

config/application.rb
# 前略
  config.action_controller.default_url_options = { trailing_slash: true }
# 後略

て書いたところ

> new_user_session_url
# こうなってほしい
"/users/sign_in/"
# けど、テスト内で呼び出すとこうなる
"/users/sign_in"

解決策

config/environments/test.rb
# 前略
  Rails.application.routes.default_url_options = { trailing_slash: true }
# 後略

て書いたところ、無事想定通りに動いた :tada:
テスト実行時とサーバー実行時でdefault_optionsの参照が変わるってことなのか…? :thinking:

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?