Responsive layout tests with Capybara and RSpec

Responsive layout tests with Capybara and RSpec

Responsive web design is not a feature these days, bur rather a must. So, while implementing responsive layout in your application, you might find helpful adding verifications to your acceptance tests and ensure accessibility/inaccessibility to your app functionality depending on the screen size.

Capybara has a method to resize the browser window:

To cover all layout breakpoints you can create responsive helpers with required browser size and default one:

And integrate it in your test. After you run a test case, the browser window should be resized back to default size:

For more details on this and other useful methods of Window, check the documentation.