rspec テスト内で confirmation ダイアログを出している場合、 accept_alert を使うと良い。

accept_alert do
  click_link('link that triggers appearance of system modal')
end
#accept_alert(text, **options) { ... } ⇒ String

Parameters:

text (String, Regexp) — Text or regex to match against the text in the modal. If not provided any modal is matched.

Options Hash (**options):

:wait (Numeric) — Maximum time to wait for the modal to appear after executing the block. Defaults to default_max_wait_time.

Method: Capybara::Session#accept_alert — Documentation for capybara (3.39.2)