From b0104e4c33e4f411fcb487e070e7cdc0818a3aad Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 31 May 2023 14:01:11 -0400 Subject: [PATCH] Silence output to stdout during cli specs (#25211) --- spec/rails_helper.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 22078a6cbc..d7e2b5c185 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -62,6 +62,10 @@ RSpec.configure do |config| config.infer_spec_type_from_file_location! config.filter_rails_from_backtrace! + config.define_derived_metadata(file_path: Regexp.new('spec/lib/mastodon/cli')) do |metadata| + metadata[:type] = :cli + end + config.include Devise::Test::ControllerHelpers, type: :controller config.include Devise::Test::ControllerHelpers, type: :helper config.include Devise::Test::ControllerHelpers, type: :view @@ -73,6 +77,10 @@ RSpec.configure do |config| config.include Redisable config.include SignedRequestHelpers, type: :request + config.before :each, type: :cli do + stub_stdout + end + config.before :each, type: :feature do https = ENV['LOCAL_HTTPS'] == 'true' Capybara.app_host = "http#{https ? 's' : ''}://#{ENV.fetch('LOCAL_DOMAIN')}" @@ -106,6 +114,10 @@ def attachment_fixture(name) Rails.root.join('spec', 'fixtures', 'files', name).open end +def stub_stdout + allow($stdout).to receive(:write) +end + def stub_jsonld_contexts! stub_request(:get, 'https://www.w3.org/ns/activitystreams').to_return(request_fixture('json-ld.activitystreams.txt')) stub_request(:get, 'https://w3id.org/identity/v1').to_return(request_fixture('json-ld.identity.txt'))