Skip to content

Commit 2055f32

Browse files
author
Sam Phippen
authored
Fix puma loading in Rails 5.1 (#1884)
* Fix puma loading in Rails 5.1 * Prevent system tests loading without capybara * Allow rescuing exceptions for system test * Fix rubocop lints
1 parent 8dbbf9e commit 2055f32

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/rspec/rails/configuration.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ def self.add_test_type_configurations(config)
5151
config.include RSpec::Rails::Matchers
5252

5353
if ActionPack::VERSION::STRING >= "5.1"
54-
config.include RSpec::Rails::SystemExampleGroup, :type => :system
54+
begin
55+
require 'puma'
56+
require 'capybara'
57+
config.include RSpec::Rails::SystemExampleGroup, :type => :system
58+
# rubocop:disable Lint/HandleExceptions
59+
rescue LoadError
60+
# rubocop:enable Lint/HandleExceptions
61+
end
5562
end
5663
end
5764

lib/rspec/rails/example.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,12 @@
99
require 'rspec/rails/example/job_example_group'
1010
require 'rspec/rails/example/feature_example_group'
1111
if ActionPack::VERSION::STRING >= "5.1"
12-
require 'rspec/rails/example/system_example_group'
12+
begin
13+
require 'puma'
14+
require 'capybara'
15+
require 'rspec/rails/example/system_example_group'
16+
# rubocop:disable Lint/HandleExceptions
17+
rescue LoadError
18+
# rubocop:enable Lint/HandleExceptions
19+
end
1320
end

0 commit comments

Comments
 (0)