Skip to content

Commit 52d1665

Browse files
committed
Merge branch 'add-puma-log-silencing' into 4-0-maintenance
Merges #2289
2 parents 69acdc4 + 12ae686 commit 52d1665

File tree

6 files changed

+52
-9
lines changed

6 files changed

+52
-9
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
language: ruby
22

3+
sudo: required
4+
addons:
5+
chrome: stable
6+
apt:
7+
packages:
8+
- chromium-chromedriver
9+
310
# We deviate from the rspec-dev cache setting here.
411
#
512
# Travis has special bundler support where it knows to run `bundle clean`
@@ -28,6 +35,7 @@ before_script:
2835
# Rails 4+ complains with a bundler rails binstub in PROJECT_ROOT/bin/
2936
- rm -f bin/rails
3037
- bundle exec rails --version
38+
- ln -s /usr/lib/chromium-browser/chromedriver ~/bin/chromedriver
3139

3240
script: "script/run_build 2>&1"
3341

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Enhancements:
77
* The scaffold generator now generates request specs in preference to controller specs.
88
(Luka Lüdicke, #2288)
99
* Add configuration option to disable ActiveRecord. (Jon Rowe, Phil Pirozhkov, Hermann Mayer, #2266)
10+
* Set `ActionDispatch::SystemTesting::Server.silence_puma = true` when running system specs.
11+
(ta1kt0me, Benoit Tigeot, #2289)
1012

1113
Bug Fixes:
1214

Gemfile-rails-dependencies

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ when /stable$/
2424
end
2525
when nil, false, ""
2626
gem "rails", "~> 6.0.0"
27+
gem "puma"
2728
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
2829
else
2930
gem "rails", version

Rakefile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,13 @@ namespace :generate do
7272
sh "bundle binstubs railties" unless File.exist?("bin/rails")
7373

7474
application_file = File.read("config/application.rb")
75+
application_file.gsub!("config.assets.enabled = true", "config.assets.enabled = false")
76+
application_file.gsub!('# require "sprockets/railtie"', 'require "sprockets/railtie"')
77+
7578
sh "rm config/application.rb"
79+
7680
File.open("config/application.rb", "w") do |f|
77-
f.write application_file.gsub(
78-
"config.assets.enabled = true",
79-
"config.assets.enabled = false"
80-
)
81+
f.write(application_file)
8182
end
8283
end
8384
end
@@ -197,12 +198,13 @@ namespace :no_active_record do
197198
sh "bundle binstubs railties" unless File.exist?("bin/rails")
198199

199200
application_file = File.read("config/application.rb")
201+
application_file.gsub!("config.assets.enabled = true", "config.assets.enabled = false")
202+
application_file.gsub!('# require "sprockets/railtie"', 'require "sprockets/railtie"')
203+
200204
sh "rm config/application.rb"
205+
201206
File.open("config/application.rb", "w") do |f|
202-
f.write application_file.gsub(
203-
"config.assets.enabled = true",
204-
"config.assets.enabled = false"
205-
)
207+
f.write(application_file)
206208
end
207209
end
208210
end

features/system_specs/system_specs.feature

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Feature: System spec
2525
javascript, you do not need [DatabaseCleaner](https://github.com/DatabaseCleaner/database_cleaner).
2626

2727
@system_test
28-
Scenario: System specs
28+
Scenario: System specs driven by rack_test
2929
Given a file named "spec/system/widget_system_spec.rb" with:
3030
"""ruby
3131
require "rails_helper"
@@ -81,3 +81,29 @@ Feature: System spec
8181
"""
8282
When I run `rspec spec/system/some_job_system_spec.rb`
8383
Then the example should pass
84+
85+
@system_test
86+
Scenario: System specs driven by selenium_chrome_headless
87+
Given a file named "spec/system/widget_system_spec.rb" with:
88+
"""ruby
89+
require "rails_helper"
90+
91+
RSpec.describe "Widget management", :type => :system do
92+
before do
93+
driven_by(:selenium_chrome_headless)
94+
end
95+
96+
it "enables me to create widgets" do
97+
visit "/widgets/new"
98+
99+
fill_in "Name", :with => "My Widget"
100+
click_button "Create Widget"
101+
102+
expect(page).to have_text("Widget was successfully created.")
103+
end
104+
end
105+
"""
106+
When I run `rspec spec/system/widget_system_spec.rb`
107+
Then the output should contain "1 example, 0 failures"
108+
And the output should not contain "starting Puma"
109+
And the exit status should be 0

lib/rspec/rails/example/system_example_group.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ def app
5050
end
5151

5252
included do |other|
53+
ActiveSupport.on_load(:action_dispatch_system_test_case) do
54+
ActionDispatch::SystemTesting::Server.silence_puma = true
55+
end
56+
5357
begin
5458
require 'capybara'
5559
require 'action_dispatch/system_test_case'

0 commit comments

Comments
 (0)