Skip to content

Commit

Permalink
[rb] Add tests for the cookie named, and updates type (SeleniumHQ#14843)
Browse files Browse the repository at this point in the history
* add tests for the cookie named, and updates type

* update gemfile lock
  • Loading branch information
aguspe authored and sandeepsuryaprasad committed Dec 3, 2024
1 parent 4977e7c commit 8fe051d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 1 addition & 3 deletions rb/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (8.0.0)
activesupport (7.2.2)
base64
benchmark (>= 0.3)
bigdecimal
Expand All @@ -25,7 +25,6 @@ GEM
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
Expand Down Expand Up @@ -162,7 +161,6 @@ GEM
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.6.0)
uri (1.0.2)
webmock (3.24.0)
addressable (>= 2.8.0)
crack (>= 0.3.2)
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/common/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def add_cookie(opts = {})
# Get the cookie with the given name
#
# @param [String] name the name of the cookie
# @return [Hash, nil] the cookie, or nil if it wasn't found.
# @return [Hash, nil] the cookie, or throws a NoSuchCookieError if it wasn't found.
#

def cookie_named(name)
Expand Down
4 changes: 2 additions & 2 deletions rb/sig/lib/selenium/webdriver/common/manager.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Selenium

def add_cookie: (?Hash[Symbol, untyped] opts) -> void

def cookie_named: (String name) -> Hash[Symbol, untyped]
def cookie_named: (String name) -> (Hash[Symbol, untyped] | Error::NoSuchCookieError)

def delete_cookie: (String name) -> String

Expand All @@ -33,7 +33,7 @@ module Selenium

def strip_port: (String str) -> String?

def convert_cookie: (Hash[String, untyped] cookie) -> Hash[Symbol, untyped]
def convert_cookie: (String) -> (Hash[Symbol, untyped] | Error::NoSuchCookieError)
end
end
end
5 changes: 5 additions & 0 deletions rb/spec/integration/selenium/webdriver/manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ module WebDriver
driver.manage.delete_all_cookies
expect(driver.manage.all_cookies).to be_empty
end

it 'throws error when fetching non-existent cookie' do
expect { driver.manage.cookie_named('non-existent') }
.to raise_exception(Error::NoSuchCookieError)
end
end
end # Options
end # WebDriver
Expand Down

0 comments on commit 8fe051d

Please sign in to comment.