Skip to content

Commit

Permalink
Merge branch 'add-puma-log-silencing' into 4-0-maintenance
Browse files Browse the repository at this point in the history
Merges #2289
  • Loading branch information
JonRowe committed Mar 24, 2020
2 parents 69acdc4 + 12ae686 commit 52d1665
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 9 deletions.
8 changes: 8 additions & 0 deletions .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`
Expand Down Expand Up @@ -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"

Expand Down
2 changes: 2 additions & 0 deletions Changelog.md
Expand Up @@ -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:

Expand Down
1 change: 1 addition & 0 deletions Gemfile-rails-dependencies
Expand Up @@ -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
Expand Down
18 changes: 10 additions & 8 deletions Rakefile
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
28 changes: 27 additions & 1 deletion features/system_specs/system_specs.feature
Expand Up @@ -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"
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions lib/rspec/rails/example/system_example_group.rb
Expand Up @@ -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'
Expand Down

0 comments on commit 52d1665

Please sign in to comment.