1. Setting cookies in the new Capybara

    12 April 2011

    Getting access to the cookie_jar is different for the new Capybara (the one that will have the acceptance test DSL)

    You’ll want to add a helper to spec/acceptance/support/cookie_helper.rb

    def cookie_jar
       Capybara.current_session.driver.browser.current_session.instance_variable_get(:@rack_mock_session).cookie_jar
    end
    

    Now you can access the cookies at any time:

    #in some scenario
    cookie_jar[:remember_token] = 'testtoken'
    

Notes

  1. bcardarella posted this