Turbo-frame not works with capybara

Currently, I’m a newbie to using rails 7 with turbo. I’m stuck with a problem the button “load more” works on the browser however when run on test capybara it only returns the white page with text. Should I need to configure it in RSpec or rails_helper?

= turbo_frame_tag 'favorite_users' do
   ....
  = link_to 'Load more', local_assigns[:url_pagination], class: 'inline-block mx-auto w-full

When run on development, I debug to check turbo_frame_request is true

But when run on test, the turbo_frame_request is false
Screen Shot 2022-04-01 at 23.30.51

The screenshot failure:

Version:

  • Ruby: 3.1.0
  • Rails: 7.0.2.3

Try putting this code in your app/controllers/application_controller.rb file

require "hotwire-rails"

class ApplicationController < ActionController::Base
  helper Turbo::FramesHelper if Rails.env.test?
  helper Turbo::StreamsHelper if Rails.env.test?
end
1 Like

@rockwell Are you sure about require "hotwire-rails"? It looks deprecated.
Currently, I’m using gem stimulus-rails & turbo-rails. I’ve tried with your code without require "hotwire-rails" but it’s same :thinking:

Well. That code hasn’t been touched since a long time. But, i remember i also had the same issue you’re facing.

And, including the FramesHelper and StreamsHelper solved it for me. I’m sorry it didn’t work for you :frowning:

1 Like

@rockwell No problem. It makes me try another solution. Currently, I’m putting the button inside a form and it works in capybara. Thank you for your solution

1 Like