Reputation: 986
After I upgraded to Qt5, some of my previously passing specs started to fail. Some of the failures are related to unreliable outgoing requests. For example, in a spec I was checking if 10 requests have been made, and the spec would fail with only n requests made, n was sometimes 2 or 3 or another, unreliably. I tried changing Capybara's default wait time, but no luck.
Here is another simpler failure. It's checking if the url changed after clicking a link:
it 'shows sorting with correct link', js: true do
expect(page).to have_content(/Sorted by/i)
expect(page).to have_selector(:link_or_button, text: /Most Recent/i)
page.find(:link_or_button, text: /A-Z/i).click
expect(current_url).to include 'sort=name'
end
And it gave me the failure:
Failure/Error: expect(current_url).to include 'sort=name'
expected "http://127.0.0.1:51355/shows" to include "sort=name"
I turned on capybara-webkit's debug mode, and it looked like it didn't actually write response to the new url:
(... previous logs ignored...)
Received "Node.leftClick"
Started "Node.leftClick"
Started request to "http://127.0.0.1:51355/shows?sort=name&status="
Finished "Node.leftClick" with response "Success()"
Wrote response true ""
Received "CurrentUrl()"
Started "CurrentUrl()"
Finished "CurrentUrl()" with response "Success(http://127.0.0.1:51355/shows)"
Wrote response true "http://127.0.0.1:51355/shows"
Received 200 from "http://127.0.0.1:51355/shows?sort=name&status="
Received "Reset()"
Started "Reset()"
Finished "Reset()" with response "Success()"
Wrote response true ""
Received "EnableLogging()"
Started "EnableLogging()"
Finished "EnableLogging()" with response "Success()"
Wrote response true ""
Received "SetUnknownUrlMode(block)"
Started "SetUnknownUrlMode(block)"
Finished "SetUnknownUrlMode(block)" with response "Success()"
Wrote response true ""
Received "SetTimeout(300)"
Started "SetTimeout(300)"
Finished "SetTimeout(300)" with response "Success()"
Wrote response true ""
shows sorting with correct link (FAILED - 1)
I wonder if anyone has experienced similar failures or how I can further investigate this issue. The specs were passing with capybara-webkit built with Qt4 but not sure why they failed with Qt5. More info about my setup:
capybara (2.7.0)
capybara-webkit (1.10.1)
rails (4.2.5.1)
rspec (3.3)
Thanks!
Upvotes: 0
Views: 95
Reputation: 49890
Actions are not guaranteed to be synchronous when using Capybara, which means you need to use the matchers provided by Capybara that will wait/retry for a little bit. In the case of your expect(current_url).to include 'sort=name'
example that should be written as
expect(page).to have_current_path(/sort=name/)
For your "number of requests made" spec we'd need to see code.
Upvotes: 1