'RSpec ignoring Turbo delete method

I have a link to delete a resource in a Rails app that works fine during manual testing but I cannot make the RSpec test for it pass. The link uses Turbo. It looks like the tests are ignoring the turbo-method, as I get the error:

Failures:                                                                                                                                                                                     
  1) user deletes a kalendar successfully                                                      cause Capybara.raise_server_errors ==      Got 1 failure and 1 other error:                                                          
                                                                                               n `raise_server_error!'
     1.1) Failure/Error: expect { click_on 'Remove calendar' }.to change { Kalendar.count }.by 
-1                                                                                             
            expected `Kalendar.count` to have changed by -1, but was changed by 0              
          # ./spec/features/user_deletes_kalendar_spec.rb:10:in `block (2 levels) in <main>'   
                                                                                               
     1.2) Failure/Error: raise ActionNotFound.new("The action '#{action}' could not be found fo
r #{self.class.name}", self, action)                                                           
                                                                                               
          AbstractController::ActionNotFound:                                                              The action 'show' could not be found for KalendarsController 

I have tried adding js: true but this doesn’t seem to make any difference.

RSpec

feature 'user deletes a kalendar' do
  let!(:kalendar) { create :kalendar }

  scenario 'successfully' do
    sign_in kalendar.user
    visit user_path(kalendar.user)
    expect { click_on 'Remove calendar' }.to change { Kalendar.count }.by -1
    expect(page).to have_content("#{kalendar.name} has been removed")
  end
end

The view

      <li>
        <strong><%= kalendar.name %></strong>
        <%= link_to "Remove calendar", kalendar_path(kalendar), data: { "turbo-method": :delete } %>
      </li>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source