元ネタ: capybaraでcurrent_pathが一致しているかどうか調べるのにハマった
問題
expect(page).to have_current_path XXX_path
とすると、current_path
にクエリパラメータ(?〜
)が付いているときにfailします。
で、どうするの?
have_current_path
にignore_query: true
オプションを指定しましょう。
expect(page).to have_current_path XXX_path, ignore_query: true
これでcurrent_path
のクエリパラメータ以降が無視されます。