0
votes

I use wicked (1.3.1) (not sure if relevant) for an onboarding flow on my rails 5 app. On the last step of my onboarding process, there is an <a> link that navigates to a user#dashboard page.

This works totally fine in all browsers. For some reason that transition does not work in Capybara (rspec 3.7, rspec-rails 3.7.2, Capybara 2.14). The url changes in the automated browser to the desired route, but the page does not render any content, it retains the old view. Visually its as if someone typed in a url but did not press return, however, the controller method and view are getting touched when i debug them. They appear to return a rendering, but the value is not rendered in the browser

If i throw a sleep in my test after the <a> click, I can manually click on the url bar, press return (to navigate to the correct url) and the page will render then. But not on its own. Anyone experience this before?

I have tried changing the href to a different path to see if it is a problem with the target view/controller - it is not, happens to all of the paths I try. I have also tried different capybara drivers: :selenium, :chrome, :poltergeist. All same result!

Would love to provide more detail but i'm not sure what to show. Its a simple href and i'm not sure what could go wrong.

Cheers

EDIT: turns out there was an error in the logs. Will update with a solution.

error:

Could not log "render_template.action_view" event. NoMethodError: undefined method `render_views?' for RSpec::ExampleGroups::LayoutsSplash::View:Class ["/Users/mitchellmeyer/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.6.0/lib/rspec/core/example_group.rb:732:in `method_missing'",
1
Check your test.log - does the request generate an error?Thomas Walpole
Another possibility is a turbolinks issue - add a data-turbolinks=“false” attribute to the link to diagnose thatThomas Walpole
@ThomasWalpole - thanks for pointing out the logs. Obviously should have looked there. Turns out there is an error. Will be looking at that now and will update this question when i resolve it. Could not log "render_template.action_view" event. NoMethodError: undefined method render_views?' for RSpec::ExampleGroups::LayoutsSplash::View:Class ["/Users/mitchellmeyer/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.6.0/lib/rspec/core/example_group.rb:732:in method_missing'",...MingMan
That's a known issue in 3.6.0 - github.com/rspec/rspec-rails/issues/1800 - update your rspec and rspec-rails - Probably not the cause of your actual issue though.Thomas Walpole
@ThomasWalpole - I updated it and the errors went away. Clean log file returning 200 at the end. Proceeded to turn turbo-links off for the <a> tag (link_to) i was referencing. If you wanna add those comments as an answer ill mark it as the correct answer! Thanks!MingMan

1 Answers

1
votes

The error shown in the logs is a know rspec/rspec-rails 3.6 issue - upgrading will fix that. Beyond that, the fact it works when a URL is submitted manually to the browser but not when clicking on the link indicates the link is probably being interfered with by JS. Most likely that's Turbolinks which you can disable for a given link by adding a data-turbolinks=“false” attribute to the link. If that fixes the behavior (which you state it did) then it's probable you have a JS error in one of your files. Check the developer console in the browser for any errors shown and fix them.

Since you mention Poltergeist, as a driver you tried, in your question it's possible for there to be silent errors that cause JS to fail when using it since it doesn't support anything beyond ES 5.1 so it's not really that suitable for testing modern webapps any more and I would recommend sticking to headless chrome if you need headless testing.