class CookieJarTest

Attributes

request[R]

Public Instance Methods

setup() click to toggle source
# File actionpack/test/dispatch/cookies_test.rb, line 11
def setup
  @request = ActionDispatch::Request.empty
end
test_each() click to toggle source
# File actionpack/test/dispatch/cookies_test.rb, line 45
def test_each
  request.cookie_jar["foo"] = :bar
  list = []
  request.cookie_jar.each do |k, v|
    list << [k, v]
  end

  assert_equal [["foo", :bar]], list
end
test_enumerable() click to toggle source
# File actionpack/test/dispatch/cookies_test.rb, line 55
def test_enumerable
  request.cookie_jar["foo"] = :bar
  actual = request.cookie_jar.map { |k, v| [k.to_s, v.to_s] }
  assert_equal [["foo", "bar"]], actual
end
test_fetch() click to toggle source
# File actionpack/test/dispatch/cookies_test.rb, line 15
def test_fetch
  x = Object.new
  assert_not request.cookie_jar.key?("zzzzzz")
  assert_equal x, request.cookie_jar.fetch("zzzzzz", x)
  assert_not request.cookie_jar.key?("zzzzzz")
end
test_fetch_block() click to toggle source
# File actionpack/test/dispatch/cookies_test.rb, line 28
def test_fetch_block
  x = Object.new
  assert_not request.cookie_jar.key?("zzzzzz")
  assert_equal x, request.cookie_jar.fetch("zzzzzz") { x }
end
test_fetch_exists() click to toggle source
# File actionpack/test/dispatch/cookies_test.rb, line 22
def test_fetch_exists
  x = Object.new
  request.cookie_jar["foo"] = "bar"
  assert_equal "bar", request.cookie_jar.fetch("foo", x)
end
test_fetch_type_error() click to toggle source
# File actionpack/test/dispatch/cookies_test.rb, line 39
def test_fetch_type_error
  assert_raises(KeyError) do
    request.cookie_jar.fetch(:omglolwut)
  end
end
test_key_is_to_s() click to toggle source
# File actionpack/test/dispatch/cookies_test.rb, line 34
def test_key_is_to_s
  request.cookie_jar["foo"] = "bar"
  assert_equal "bar", request.cookie_jar.fetch(:foo)
end
test_key_methods() click to toggle source
# File actionpack/test/dispatch/cookies_test.rb, line 61
def test_key_methods
  assert !request.cookie_jar.key?(:foo)
  assert !request.cookie_jar.has_key?("foo")

  request.cookie_jar[:foo] = :bar
  assert request.cookie_jar.key?(:foo)
  assert request.cookie_jar.has_key?("foo")
end
test_write_doesnt_set_a_nil_header() click to toggle source
# File actionpack/test/dispatch/cookies_test.rb, line 70
def test_write_doesnt_set_a_nil_header
  headers = {}
  request.cookie_jar.write(headers)
  assert_not_includes headers, "Set-Cookie"
end