diff --git a/.travis.yml b/.travis.yml index cce3afa0b5..35789781d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,12 @@ language: ruby +sudo: required +addons: + chrome: stable + apt: + packages: + - chromium-chromedriver + # We deviate from the rspec-dev cache setting here. # # Travis has special bundler support where it knows to run `bundle clean` @@ -28,6 +35,7 @@ before_script: # Rails 4+ complains with a bundler rails binstub in PROJECT_ROOT/bin/ - rm -f bin/rails - bundle exec rails --version + - ln -s /usr/lib/chromium-browser/chromedriver ~/bin/chromedriver script: "script/run_build 2>&1" diff --git a/Changelog.md b/Changelog.md index bd4b157507..ad56f32881 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,8 @@ Enhancements: * The scaffold generator now generates request specs in preference to controller specs. (Luka Lüdicke, #2288) * Add configuration option to disable ActiveRecord. (Jon Rowe, Phil Pirozhkov, Hermann Mayer, #2266) +* Set `ActionDispatch::SystemTesting::Server.silence_puma = true` when running system specs. + (ta1kt0me, Benoit Tigeot, #2289) Bug Fixes: diff --git a/Gemfile-rails-dependencies b/Gemfile-rails-dependencies index 6fff9b2a02..52788883b9 100644 --- a/Gemfile-rails-dependencies +++ b/Gemfile-rails-dependencies @@ -24,6 +24,7 @@ when /stable$/ end when nil, false, "" gem "rails", "~> 6.0.0" + gem "puma" gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby] else gem "rails", version diff --git a/Rakefile b/Rakefile index a501783ca8..5a0b085066 100644 --- a/Rakefile +++ b/Rakefile @@ -72,12 +72,13 @@ namespace :generate do sh "bundle binstubs railties" unless File.exist?("bin/rails") application_file = File.read("config/application.rb") + application_file.gsub!("config.assets.enabled = true", "config.assets.enabled = false") + application_file.gsub!('# require "sprockets/railtie"', 'require "sprockets/railtie"') + sh "rm config/application.rb" + File.open("config/application.rb", "w") do |f| - f.write application_file.gsub( - "config.assets.enabled = true", - "config.assets.enabled = false" - ) + f.write(application_file) end end end @@ -197,12 +198,13 @@ namespace :no_active_record do sh "bundle binstubs railties" unless File.exist?("bin/rails") application_file = File.read("config/application.rb") + application_file.gsub!("config.assets.enabled = true", "config.assets.enabled = false") + application_file.gsub!('# require "sprockets/railtie"', 'require "sprockets/railtie"') + sh "rm config/application.rb" + File.open("config/application.rb", "w") do |f| - f.write application_file.gsub( - "config.assets.enabled = true", - "config.assets.enabled = false" - ) + f.write(application_file) end end end diff --git a/features/system_specs/system_specs.feature b/features/system_specs/system_specs.feature index 189ee62efc..2ef93f6e54 100644 --- a/features/system_specs/system_specs.feature +++ b/features/system_specs/system_specs.feature @@ -25,7 +25,7 @@ Feature: System spec javascript, you do not need [DatabaseCleaner](https://github.com/DatabaseCleaner/database_cleaner). @system_test - Scenario: System specs + Scenario: System specs driven by rack_test Given a file named "spec/system/widget_system_spec.rb" with: """ruby require "rails_helper" @@ -81,3 +81,29 @@ Feature: System spec """ When I run `rspec spec/system/some_job_system_spec.rb` Then the example should pass + + @system_test + Scenario: System specs driven by selenium_chrome_headless + Given a file named "spec/system/widget_system_spec.rb" with: + """ruby + require "rails_helper" + + RSpec.describe "Widget management", :type => :system do + before do + driven_by(:selenium_chrome_headless) + end + + it "enables me to create widgets" do + visit "/widgets/new" + + fill_in "Name", :with => "My Widget" + click_button "Create Widget" + + expect(page).to have_text("Widget was successfully created.") + end + end + """ + When I run `rspec spec/system/widget_system_spec.rb` + Then the output should contain "1 example, 0 failures" + And the output should not contain "starting Puma" + And the exit status should be 0 diff --git a/lib/rspec/rails/example/system_example_group.rb b/lib/rspec/rails/example/system_example_group.rb index f5a63cd7c1..691b1f0c28 100644 --- a/lib/rspec/rails/example/system_example_group.rb +++ b/lib/rspec/rails/example/system_example_group.rb @@ -50,6 +50,10 @@ def app end included do |other| + ActiveSupport.on_load(:action_dispatch_system_test_case) do + ActionDispatch::SystemTesting::Server.silence_puma = true + end + begin require 'capybara' require 'action_dispatch/system_test_case'