Skip to content

Commit

Permalink
add tests for the cookie named, and updates type
Browse files Browse the repository at this point in the history
  • Loading branch information
aguspe committed Dec 2, 2024
1 parent dd8c914 commit 88d80ba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
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 88d80ba

Please sign in to comment.