Skip to content

Check for puma and capybara when defining system tests #1893

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

Merged
merged 2 commits into from
Oct 25, 2017
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
12 changes: 1 addition & 11 deletions lib/rspec/rails/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,7 @@ def self.add_test_type_configurations(config)
config.include RSpec::Rails::ViewExampleGroup, :type => :view
config.include RSpec::Rails::FeatureExampleGroup, :type => :feature
config.include RSpec::Rails::Matchers

if ActionPack::VERSION::STRING >= "5.1"
begin
require 'puma'
require 'capybara'
config.include RSpec::Rails::SystemExampleGroup, :type => :system
# rubocop:disable Lint/HandleExceptions
rescue LoadError
# rubocop:enable Lint/HandleExceptions
end
end
config.include RSpec::Rails::SystemExampleGroup, :type => :system
end

# @private
Expand Down
11 changes: 1 addition & 10 deletions lib/rspec/rails/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,4 @@
require 'rspec/rails/example/model_example_group'
require 'rspec/rails/example/job_example_group'
require 'rspec/rails/example/feature_example_group'
if ActionPack::VERSION::STRING >= "5.1"
begin
require 'puma'
require 'capybara'
require 'rspec/rails/example/system_example_group'
# rubocop:disable Lint/HandleExceptions
rescue LoadError
# rubocop:enable Lint/HandleExceptions
end
end
require 'rspec/rails/example/system_example_group'
32 changes: 30 additions & 2 deletions lib/rspec/rails/example/system_example_group.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
if ActionPack::VERSION::STRING >= "5.1"
require 'action_dispatch/system_test_case'
can_load_system_tests = false
begin
require 'puma'
require 'capybara'
if ActionPack::VERSION::STRING >= "5.1"
require 'action_dispatch/system_test_case'
can_load_system_tests = true
end
# rubocop:disable Lint/HandleExceptions
rescue LoadError
# rubocop:enable Lint/HandleExceptions
end

if !can_load_system_tests
module RSpec
module Rails
module SystemExampleGroup
extend ActiveSupport::Concern

included do
abort """
System test integration requires Rails >= 5.1 and has a hard
dependency on `puma` and `capybara`, please add these to your
Gemfile before attempting to use system tests.
"""
end
end
end
end
else
module RSpec
module Rails
# @api public
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/example/system_example_group_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec_helper"
module RSpec::Rails
if defined?(SystemExampleGroup)
if ActionPack::VERSION::STRING >= "5.1"
RSpec.describe SystemExampleGroup do
it_behaves_like "an rspec-rails example group mixin", :system,
'./spec/system/', '.\\spec\\system\\'
Expand Down