Responsive tests
amnesia7 opened this issue · 3 comments
I saw this http://railsware.com/blog/2015/02/11/responsive-layout-tests-with-capybara-and-rspec/ and thought it might be a good addition to the rspec examples.
I'm not entirely sure how it would be best applied because I couldn't actually get it to work when using the poltergeist
driver so I assume it relies on the selenium
driver which is a shame if it can't be tested headless because that does add a lot of time onto the test run.
Unless there's a way to setup the driver multiple times with different window sizes (mobile, tablet, desktop, default, etc) at the start and then switch to the relevant one similar to what has been done for the date input tests (https://github.com/eliotsykes/rspec-rails-examples/blob/master/spec/features/subscribe_to_newsletter_spec.rb#L5).
@amnesia7 good article, thanks for sharing.
If a feature spec with responsive tests like this was added - I'm trying to think of what could be tested - possibly some nav that changes signficantly based on window width.
It looks like the poltergeist driver has a resize method: http://www.rubydoc.info/gems/poltergeist/Capybara/Poltergeist/Driver#resize-instance_method
Yeah, within a scenario you can do page.driver.resize(767, 480)
. Looks like you can also do page.driver.resize_window(767, 480)
I assume this window size change only applies to the current test being run and doesn't need to be reset again.
Navbar would probably be something that a lot of users can relate to that tests for .navbar-toggle
hidden and .navbar-collapse
visible when desktop and then .navbar-toggle
visible and .navbar-collapse
hidden when mobile [and tablet, maybe].