Class: TestyCookie::Jar

Inherits:
Object
  • Object
show all
Defined in:
lib/testy_cookie/jar.rb

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Jar

Returns a new instance of Jar.

Parameters:

  • context (ActionController::TestCase, ActionDispatch::IntegrationTest, RSpec::ExampleGroup)

    the test context



4
5
6
# File 'lib/testy_cookie/jar.rb', line 4

def initialize(context)
  @context = context
end

Instance Method Details

#cookiesActionDispatch::Cookies::CookieJar

Returns the cookie jar to use.

Returns:

  • (ActionDispatch::Cookies::CookieJar)

    the cookie jar to use



9
10
11
12
13
14
15
# File 'lib/testy_cookie/jar.rb', line 9

def cookies
  if @context.cookies.is_a?(ActionDispatch::Cookies::CookieJar)
    @context.cookies
  else
    Proxy.new(response_cookies || request_cookies, @context.cookies, nil)
  end
end