module WindowSizeHelper def resize_window_to(width, height) old_size = Capybara.current_session.current_window.size Capybara.current_session.current_window.resize_to(width, height) yield Capybara.current_session.current_window.resize_to(*old_size) end def set_window_size_permanently_to(width, height) Capybara.current_session.current_window.resize_to(width, height) end end RSpec.configure do |config| config.include WindowSizeHelper, type: :feature end