Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ferrum 0.16 #283

Merged
merged 1 commit into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion cuprite.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ Gem::Specification.new do |s|
s.required_ruby_version = ">= 2.7.0"

s.add_runtime_dependency "capybara", "~> 3.0"
s.add_runtime_dependency "ferrum", "~> 0.15.0"
s.add_runtime_dependency "ferrum", "~> 0.16.0"
end
2 changes: 1 addition & 1 deletion lib/capybara/cuprite/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def set(value, options = {})
command(:set, value.to_s)
elsif self[:isContentEditable]
command(:delete_text)
send_keys(value.to_s)
click.type(value.to_s)
end
end

Expand Down
5 changes: 4 additions & 1 deletion spec/features/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,10 @@ def create_screenshot(file, *args)

context "basic http authentication" do
it "denies without credentials" do
@session.visit "/cuprite/basic_auth"
expect { @session.visit "/cuprite/basic_auth" }.to raise_error(
Ferrum::StatusError,
%r{Request to http://.*/cuprite/basic_auth failed \(net::ERR_INVALID_AUTH_CREDENTIALS\)}
)

expect(@session.status_code).to eq(401)
expect(@session).not_to have_content("Welcome, authenticated client")
Expand Down
16 changes: 11 additions & 5 deletions spec/support/test_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class TestApp
CUPRITE_VIEWS = "#{File.dirname(__FILE__)}/views"
CUPRITE_PUBLIC = "#{File.dirname(__FILE__)}/public"

set :erb, layout: File.read("#{CUPRITE_VIEWS}/layout.erb")

helpers do
def requires_credentials(login, password)
return if authorized?(login, password)
Expand Down Expand Up @@ -67,17 +69,17 @@ def authorized?(login, password)
sleep 1
cookie_value = "test_cookie"
response.set_cookie("stealth", cookie_value)
"Cookie set to #{cookie_value}"
render_string("Cookie set to #{cookie_value}")
end

get "/cuprite/slow" do
sleep 0.2
"slow page"
render_string("slow page")
end

get "/cuprite/really_slow" do
sleep 3
"really slow page"
render_string("really slow page")
end

get "/cuprite/basic_auth" do
Expand All @@ -87,13 +89,13 @@ def authorized?(login, password)

post "/cuprite/post_basic_auth" do
requires_credentials("login", "pass")
"Authorized POST request"
render_string("Authorized POST request")
end

get "/cuprite/cacheable" do
cache_control :public, max_age: 60
etag "deadbeef"
"Cacheable request <a href='/cuprite/cacheable'>click me</a>"
render_string("Cacheable request <a href='/cuprite/cacheable'>click me</a>")
end

get "/cuprite/:view" do |view|
Expand All @@ -110,4 +112,8 @@ def authorized?(login, password)
def render_view(view)
erb File.read("#{CUPRITE_VIEWS}/#{view}.erb")
end

def render_string(str)
erb str
end
end
11 changes: 11 additions & 0 deletions spec/support/views/layout.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<!-- this disable favicon.ico request for headless browser, so not mix with other requests -->
<link rel="icon" href="data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA=" />
</head>
<body>
<%= yield %>
</body>
</html>
Loading