Reputation: 4388
I am new to write integration tests in rails. Let's say i have below scenarios,
So currently for every scenario , it opens a new browser window (or may be resetting the session). As for login we are using 3rd party oauth it takes huge amount of time for login.
So i do not want to login for each scenario. Once after login it should execute scenarios one by one without asking for login again and again. But i am not sure how to achieve the same using rspec and selenium.
Any help would be greatly appreciated .
Upvotes: 1
Views: 1364
Reputation: 4388
Capybara.current_session.instance_variable_set(:@touched, false)
Executing the above after each scenario maintains the session.
Upvotes: 3
Reputation: 49870
Selenium shouldn't be opening a new browser window for each scenario (unless you're specifically closing the tab in an after block), but it should reset it to about:blank
. As for the rest of your request, it would be completely bypassing the intention of feature/integration tests where each test should be completely isolated from the other tests. What you should be doing, if you don't want to manually login for each test, is using the test mode of whatever auth library you're using to allow you to shortcut the login.
For instance, if using OmniAuth - see https://github.com/omniauth/omniauth/wiki/Integration-Testing
Upvotes: 0