Skip to content

Commit 76a40ce

Browse files
Use capybara-lockstep (#1277)
* Require test gems separately to avoid having them in development. * Add capybara-lockstep script to the page.
1 parent a5da6c1 commit 76a40ce

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

Gemfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ source "https://rubygems.org"
55
gemspec
66

77
gem "better_html"
8-
gem "capybara"
98
gem "debug"
10-
gem "mocha"
119
gem "puma"
1210
if !@rails_gem_requirement
1311
gem "rails", ">= 7.1"
@@ -19,7 +17,6 @@ else
1917
end
2018
gem "rubocop"
2119
gem "rubocop-shopify"
22-
gem "selenium-webdriver"
2320
gem "sprockets-rails"
2421
if @sqlite3_requirement
2522
# causes Dependabot to ignore the next line and update the next gem "sqlite3"
@@ -29,3 +26,10 @@ else
2926
gem "sqlite3"
3027
end
3128
gem "yard"
29+
30+
group :test do
31+
gem "capybara"
32+
gem "capybara-lockstep"
33+
gem "mocha"
34+
gem "selenium-webdriver"
35+
end

Gemfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ GEM
107107
rack-test (>= 0.6.3)
108108
regexp_parser (>= 1.5, < 3.0)
109109
xpath (~> 3.2)
110+
capybara-lockstep (2.2.3)
111+
activesupport (>= 4.2)
112+
capybara (>= 3.0)
113+
ruby2_keywords
114+
selenium-webdriver (>= 4.0)
110115
concurrent-ruby (1.3.5)
111116
connection_pool (2.5.3)
112117
crass (1.0.6)
@@ -316,6 +321,7 @@ PLATFORMS
316321
DEPENDENCIES
317322
better_html
318323
capybara
324+
capybara-lockstep
319325
debug
320326
maintenance_tasks!
321327
mocha

app/controllers/maintenance_tasks/application_controller.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ class ApplicationController < MaintenanceTasks.parent_controller.constantize
1313
# <style> tag in app/views/layouts/maintenance_tasks/application.html.erb
1414
"'sha256-WHHDQLdkleXnAN5zs0GDXC5ls41CHUaVsJtVpaNx+EM='",
1515
)
16+
capybara_lockstep_scripts = [
17+
"'sha256-1AoN3ZtJC5OvqkMgrYvhZjp4kI8QjJjO7TAyKYiDw+U='",
18+
"'sha256-QVSzZi6ZsX/cu4h+hIs1iVivG1BxUmJggiEsGDIXBG0='", # with debug on
19+
] if defined?(Capybara::Lockstep)
1620
policy.script_src_elem(
1721
# <script> tag in app/views/layouts/maintenance_tasks/application.html.erb
1822
"'sha256-NiHKryHWudRC2IteTqmY9v1VkaDUA/5jhgXkMTkgo2w='",
23+
# <script> tag for capybara-lockstep
24+
*capybara_lockstep_scripts,
1925
)
2026

2127
policy.require_trusted_types_for # disable because we use new DOMParser().parseFromString

app/views/layouts/maintenance_tasks/application.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<%= capybara_lockstep if defined?(Capybara::Lockstep) %>
67

78
<title>
89
<% if content_for?(:page_title) %>

0 commit comments

Comments
 (0)