Skip to content

Commit d18d515

Browse files
committed
Fix Capybara screenshots in feature specs
@chrislo & I accidentally removed the screenshotting capability in #6669 at the same time as we removed the redundant configuration for running feature specs in a browser using the cuprite driver, because we were under the mistaken impression that rack-test driver did not support screenshots. As @murugapl & @misaka pointed out, capybara-screenshot does actually support HTML screenshots when using rack-test. These screenshots are improved by setting `Capybara.asset_host = "http://localhost:4000"` so that assets can be loaded if you have the Rails app running locally. This commit partially reverts this commit [1] to restore the screenshotting behaviour. [1]: 0a95de7
1 parent e00291c commit d18d515

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ end
117117

118118
group :test do
119119
gem "capybara"
120+
gem "capybara-screenshot"
120121
gem "capybara_accessible_selectors",
121122
github: "citizensadvice/capybara_accessible_selectors"
122123
gem "climate_control"

Gemfile.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,18 @@ GEM
240240
rack-test (>= 0.6.3)
241241
regexp_parser (>= 1.5, < 3.0)
242242
xpath (~> 3.2)
243+
capybara-screenshot (1.0.27)
244+
capybara (>= 1.0, < 4)
245+
launchy
243246
caxlsx (4.4.2)
244247
htmlentities (~> 4.3, >= 4.3.4)
245248
marcel (~> 1.0)
246249
nokogiri (~> 1.10, >= 1.10.4)
247250
rubyzip (>= 2.4, < 4)
248251
cgi (0.5.1)
249252
charlock_holmes (0.7.9)
253+
childprocess (5.1.0)
254+
logger (~> 1.5)
250255
climate_control (1.2.0)
251256
coderay (1.1.3)
252257
concurrent-ruby (1.3.6)
@@ -435,6 +440,10 @@ GEM
435440
kramdown-parser-gfm (1.1.0)
436441
kramdown (~> 2.0)
437442
language_server-protocol (3.17.0.5)
443+
launchy (3.1.1)
444+
addressable (~> 2.8)
445+
childprocess (~> 5.0)
446+
logger (~> 1.6)
438447
lint_roller (1.1.0)
439448
listen (3.9.0)
440449
rb-fsevent (~> 0.10, >= 0.10.3)
@@ -935,6 +944,7 @@ DEPENDENCIES
935944
bootsnap
936945
brakeman
937946
capybara
947+
capybara-screenshot
938948
capybara_accessible_selectors!
939949
caxlsx
940950
charlock_holmes

spec/spec_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,13 @@
108108
end
109109
require "rspec/rails"
110110
# Add additional requires below this line. Rails is not loaded until this point!
111+
require 'capybara-screenshot/rspec'
111112
require "rack_session_access/capybara"
112113
require "console"
113114

114115
Faker::Config.locale = "en-GB"
115116

117+
Capybara.asset_host = "http://localhost:4000"
116118
Console.logger.off!
117119
Capybara.server = :falcon
118120

0 commit comments

Comments
 (0)