Module: Riot::Gear::PersistCookie

Defined in:
lib/riot/gear/context/persist_cookie.rb

Instance Method Summary collapse

Instance Method Details

Graft a cookie (name and value) from the last response onto the next and subsequent requests. Only applies to multiple requests within a Context. For instance, if you log into your service, you will probably want to pass along whatever the session cookie was to the next request in the test.

context "Get new messages" do
  base_uri "http://example.com"
  post "/[email protected]&password=beepboopbop"

  persist_cookie("example_session")

  get "/user/messages.json"
  asserts_status.equals(200)
  asserts_json("messages").length(8)
end

Parameters:

  • cookie_name (String)

    the name of a cookie to persist

Returns:

  • (Riot::Assertion)

    an assertion block that macros can be applied to



25
26
27
28
29
30
31
# File 'lib/riot/gear/context/persist_cookie.rb', line 25

def persist_cookie(cookie_name)
  hookup do
    if cookie_value = cookie_values[cookie_name]
      topic.cookies({cookie_name => cookie_value["value"]})
    end
  end
end