From 093f261ab8765ba5dd685ddb5b345e4925b5b035 Mon Sep 17 00:00:00 2001 From: ta1kt0me Date: Sat, 14 Jul 2018 12:52:33 +0900 Subject: [PATCH 1/8] Make puma log silence completely --- features/system_specs/system_specs.feature | 28 ++++++++++++++++++- .../rails/example/system_example_group.rb | 6 +++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/features/system_specs/system_specs.feature b/features/system_specs/system_specs.feature index 189ee62efc..a9278204d0 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 exit status should be 0 + And the output should contain "1 example, 0 failures" + And the output should not contain "Puma starting" diff --git a/lib/rspec/rails/example/system_example_group.rb b/lib/rspec/rails/example/system_example_group.rb index f5a63cd7c1..9ea1c25e93 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' @@ -77,7 +81,7 @@ def app attr_reader :driver - if ActionDispatch::SystemTesting::Server.respond_to?(:silence_puma=) + if ::Rails.version.to_f == 5.1 ActionDispatch::SystemTesting::Server.silence_puma = true end From 267616e1377b66a74080dece97f71166e07f344c Mon Sep 17 00:00:00 2001 From: ta1kt0me Date: Wed, 1 Aug 2018 00:31:46 +0900 Subject: [PATCH 2/8] Enable chrome on travisci --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) 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" From b22480cb1b3c1e061aaa82218113771c104773ac Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 16 Mar 2020 17:20:00 +0100 Subject: [PATCH 3/8] Do no stick patch to 5.1 Close: https://github.com/rspec/rspec-rails/pull/2011#discussion_r232241661 --- lib/rspec/rails/example/system_example_group.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rspec/rails/example/system_example_group.rb b/lib/rspec/rails/example/system_example_group.rb index 9ea1c25e93..691b1f0c28 100644 --- a/lib/rspec/rails/example/system_example_group.rb +++ b/lib/rspec/rails/example/system_example_group.rb @@ -81,7 +81,7 @@ def app attr_reader :driver - if ::Rails.version.to_f == 5.1 + if ActionDispatch::SystemTesting::Server.respond_to?(:silence_puma=) ActionDispatch::SystemTesting::Server.silence_puma = true end From 6ee70f39ce9ecfa0e16aa3a0b6d078e98d0804d3 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 16 Mar 2020 23:55:45 +0100 Subject: [PATCH 4/8] We need to explicit require puma in order to use selenium driver --- Gemfile-rails-dependencies | 1 + 1 file changed, 1 insertion(+) 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 From fedff2db899c8da74be1c25516eb49ab50249320 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 16 Mar 2020 23:56:43 +0100 Subject: [PATCH 5/8] Enable railtie otherwise capybara breaks with a 404 Avoid: 1) Widget management enables me to create widgets Failure/Error: raise ActionController::RoutingError, "No route matches [#{env['REQUEST_METHOD']}] #{env['PATH_INFO'].inspect}" ActionController::RoutingError: No route matches [GET] "/stylesheets/application.css" --- Rakefile | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) 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 From 99e47cb9b2c8451d4963510a0dc21e01a4b9aa25 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Tue, 17 Mar 2020 00:02:20 +0100 Subject: [PATCH 6/8] Reorder expectations to be more easily debugable --- features/system_specs/system_specs.feature | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/features/system_specs/system_specs.feature b/features/system_specs/system_specs.feature index a9278204d0..2ef93f6e54 100644 --- a/features/system_specs/system_specs.feature +++ b/features/system_specs/system_specs.feature @@ -104,6 +104,6 @@ Feature: System spec end """ When I run `rspec spec/system/widget_system_spec.rb` - Then the exit status should be 0 - And the output should contain "1 example, 0 failures" - And the output should not contain "Puma starting" + Then the output should contain "1 example, 0 failures" + And the output should not contain "starting Puma" + And the exit status should be 0 From a902cfdbcca69a70e23d9285ccfcfbf45870cccf Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Tue, 17 Mar 2020 00:44:09 +0100 Subject: [PATCH 7/8] Add changelog for #2011 --- Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.md b/Changelog.md index bd4b157507..163c9f5314 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,7 @@ 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) +* Remove Puma log when running system specs. (ta1kt0me, Benoit Tigeot, #2011) Bug Fixes: From 12ae686247e333cab29fd9dd12af56238aec3883 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Tue, 17 Mar 2020 13:22:53 +0100 Subject: [PATCH 8/8] Refers changelog PR to #2289 Co-Authored-By: Jon Rowe --- Changelog.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 163c9f5314..ad56f32881 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,7 +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) -* Remove Puma log when running system specs. (ta1kt0me, Benoit Tigeot, #2011) +* Set `ActionDispatch::SystemTesting::Server.silence_puma = true` when running system specs. + (ta1kt0me, Benoit Tigeot, #2289) Bug Fixes: