0
0
Fork 0

Add coverage for CLI::Cache command (#25238)

This commit is contained in:
Matt Jankowski 2023-06-10 12:36:09 -04:00 committed by GitHub
parent 215081240f
commit 07933db788
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 113 additions and 14 deletions

View file

@ -79,6 +79,7 @@ RSpec.configure do |config|
config.before :each, type: :cli do
stub_stdout
stub_reset_connection_pools
end
config.before :each, type: :feature do
@ -121,9 +122,20 @@ def attachment_fixture(name)
end
def stub_stdout
# TODO: Is there a bettery way to:
# - Avoid CLI command output being printed out
# - Allow rspec to assert things against STDOUT
# - Avoid disabling stdout for other desirable output (deprecation warnings, for example)
allow($stdout).to receive(:write)
end
def stub_reset_connection_pools
# TODO: Is there a better way to correctly run specs without stubbing this?
# (Avoids reset_connection_pools! in test env)
allow(ActiveRecord::Base).to receive(:establish_connection)
allow(RedisConfiguration).to receive(:establish_pool)
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'))