For test runtime in Capybara 2.2.4 version, you can achieve this by doing
before do
handle = Capybara.page.driver.current_window_handle
Capybara.page.driver.resize_window_to(handle, height, width)
end
Or
before do
Capybara.page.current_window.resize_to(height, width)
end
If you encounter an error like this "Capybara::NotSupportedByDriverError: Capybara::Driver::Base#current_window_handle" I suggest you change your WebDriver
before do
Capybara.page.current_window.resize_to(height, width)
end
scenario js: true do
# your test here
end