Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions spec/support/cookie_jar.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
# frozen_string_literal: true

require 'uri'

module Rack
class MockResponse
def cookie_jar
@cookie_jar ||= Array(headers[Rack::SET_COOKIE]).flat_map { |h| h.split("\n") }.map { |c| Cookie.new(c).to_h }
end

module Spec
module Support
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie
class Cookie
class CookieJar
attr_reader :attributes

def initialize(raw)
Expand Down Expand Up @@ -52,3 +47,11 @@ def parse_value(attribute, value)
end
end
end

module Rack
class MockResponse
def cookie_jar
@cookie_jar ||= Array(headers[Rack::SET_COOKIE]).flat_map { |h| h.split("\n") }.map { |c| Spec::Support::CookieJar.new(c).to_h }
end
end
end
Loading