Skip to content

Commit

Permalink
Extra cookie params (#371)
Browse files Browse the repository at this point in the history
* Added missing specs for `Ferrum::Cookies::Cookie`.

* Added additional cookie params to `Ferrum::Cookies::Cookie`.

* Chrome Devtools Protocol 1.3 includes additional new params for
  cookies.
  • Loading branch information
postmodern authored Jul 13, 2023
1 parent e4d4044 commit 38d0efa
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
32 changes: 32 additions & 0 deletions lib/ferrum/cookies/cookie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,38 @@ def expires
Time.at(attributes["expires"]) if attributes["expires"].positive?
end

#
# The priority of the cookie.
#
# @return [String]
#
def priority
@attributes['priority']
end

#
# @return [Boolean]
#
def sameparty?
@attributes['sameParty']
end

alias same_party? sameparty?

#
# @return [String]
#
def source_scheme
@attributes['sourceScheme']
end

#
# @return [Integer]
#
def source_port
@attributes['sourcePort']
end

#
# Compares different cookie objects.
#
Expand Down
24 changes: 24 additions & 0 deletions spec/cookies/cookie_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,30 @@
end
end

describe "#priority" do
it "must return the 'priority' attribute" do
expect(subject.priority).to eq(attributes['priority'])
end
end

describe "#sameparty?" do
it "must return the 'sameParty' attribute" do
expect(subject.sameparty?).to eq(attributes['sameParty'])
end
end

describe "#source_scheme" do
it "must return the 'sourceScheme' attribute" do
expect(subject.source_scheme).to eq(attributes['sourceScheme'])
end
end

describe "#source_port" do
it "must return the 'sourcePort' attribute" do
expect(subject.source_port).to eq(attributes['sourcePort'])
end
end

describe "#==" do
context "when given a #{described_class}" do
context "and the other #{described_class}'s attributes are the same" do
Expand Down

0 comments on commit 38d0efa

Please sign in to comment.