0
0
Fork 0

Formalize some patterns in cli specs (#28255)

This commit is contained in:
Matt Jankowski 2023-12-07 08:49:14 -05:00 committed by GitHub
parent 5d97a897c8
commit ad34d33bfd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 492 additions and 449 deletions

View file

@ -4,20 +4,26 @@ require 'rails_helper'
require 'mastodon/cli/maintenance'
describe Mastodon::CLI::Maintenance do
subject { cli.invoke(action, arguments, options) }
let(:cli) { described_class.new }
let(:arguments) { [] }
let(:options) { {} }
it_behaves_like 'CLI Command'
describe '#fix_duplicates' do
let(:action) { :fix_duplicates }
context 'when the database version is too old' do
before do
allow(ActiveRecord::Migrator).to receive(:current_version).and_return(2000_01_01_000000) # Earlier than minimum
end
it 'Exits with error message' do
expect { cli.invoke :fix_duplicates }.to output(
a_string_including('is too old')
).to_stdout.and raise_error(SystemExit)
expect { subject }
.to output_results('is too old')
.and raise_error(SystemExit)
end
end
@ -28,9 +34,9 @@ describe Mastodon::CLI::Maintenance do
end
it 'Exits with error message' do
expect { cli.invoke :fix_duplicates }.to output(
a_string_including('more recent')
).to_stdout.and raise_error(SystemExit)
expect { subject }
.to output_results('more recent')
.and raise_error(SystemExit)
end
end
@ -41,9 +47,9 @@ describe Mastodon::CLI::Maintenance do
end
it 'Exits with error message' do
expect { cli.invoke :fix_duplicates }.to output(
a_string_including('Sidekiq is running')
).to_stdout.and raise_error(SystemExit)
expect { subject }
.to output_results('Sidekiq is running')
.and raise_error(SystemExit)
end
end
end