capybara nokogiri system/request test debugging
Rails
RSpec
module RequestTestHelpers
def turbo_stream_page
# turbo_stream wraps response in <template> tag, Capybara ignore template tags
template_content = Nokogiri(response.body).css('template').inner_html
Capybara.string(template_content)
end
def follow_redirects_until_finished!
while response.status == 302 || response.status == 301
follow_redirect!
end
end
# just debugging to show the HTML of the response
def _xx(css='body')
puts Nokogiri::HTML(body).css(css).to_xhtml(indent: 2)
end
end