Skip to content
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

Make puma log silence completely #2289

Merged
merged 8 commits into from Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
1 change: 1 addition & 0 deletions Changelog.md
Expand Up @@ -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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I reference this one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

benoittgt marked this conversation as resolved.
Show resolved Hide resolved

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"')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I felt quite dirty to do this.


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