Skip to content

Instantly share code, notes, and snippets.

@odlp
Created July 25, 2017 10:57
Show Gist options
  • Save odlp/af102fa797e6bfc458734e3240859efc to your computer and use it in GitHub Desktop.
Save odlp/af102fa797e6bfc458734e3240859efc to your computer and use it in GitHub Desktop.
Capybara temporarily resize window
def with_mobile_window_size(&block)
original_size = page.current_window.size
page.current_window.resize_to(320, 480)
block.call
ensure
page.current_window.resize_to(*original_size)
end
# Usage
with_mobile_window_size do
expect(find("foo")).to have_content "x"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment