Add shared example for CLI command specs (#28165)

th-downstream
Matt Jankowski 11 months ago committed by GitHub
parent 92fa9b109f
commit 7753e5f715
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,6 +6,8 @@ require 'mastodon/cli/accounts'
describe Mastodon::CLI::Accounts do
let(:cli) { described_class.new }
it_behaves_like 'CLI Command'
# `parallelize_with_progress` cannot run in transactions, so instead,
# stub it with an alternative implementation that runs sequentially
# and can run in transactions.
@ -24,12 +26,6 @@ describe Mastodon::CLI::Accounts do
end
end
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
describe '#create' do
shared_examples 'a new user with given email address and username' do
it 'creates a new user with the specified email address' do

@ -6,11 +6,7 @@ require 'mastodon/cli/cache'
describe Mastodon::CLI::Cache do
let(:cli) { described_class.new }
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe '#clear' do
before { allow(Rails.cache).to receive(:clear) }

@ -6,11 +6,7 @@ require 'mastodon/cli/canonical_email_blocks'
describe Mastodon::CLI::CanonicalEmailBlocks do
let(:cli) { described_class.new }
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe '#find' do
let(:arguments) { ['user@example.com'] }

@ -4,9 +4,5 @@ require 'rails_helper'
require 'mastodon/cli/domains'
describe Mastodon::CLI::Domains do
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
end

@ -4,9 +4,5 @@ require 'rails_helper'
require 'mastodon/cli/email_domain_blocks'
describe Mastodon::CLI::EmailDomainBlocks do
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
end

@ -4,9 +4,5 @@ require 'rails_helper'
require 'mastodon/cli/emoji'
describe Mastodon::CLI::Emoji do
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
end

@ -6,11 +6,7 @@ require 'mastodon/cli/feeds'
describe Mastodon::CLI::Feeds do
let(:cli) { described_class.new }
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe '#build' do
before { Fabricate(:account) }

@ -6,11 +6,7 @@ require 'mastodon/cli/ip_blocks'
describe Mastodon::CLI::IpBlocks do
let(:cli) { described_class.new }
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe '#add' do
let(:ip_list) do

@ -4,11 +4,7 @@ require 'rails_helper'
require 'mastodon/cli/main'
describe Mastodon::CLI::Main do
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe 'version' do
it 'returns the Mastodon version' do

@ -6,11 +6,7 @@ require 'mastodon/cli/maintenance'
describe Mastodon::CLI::Maintenance do
let(:cli) { described_class.new }
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe '#fix_duplicates' do
context 'when the database version is too old' do

@ -6,11 +6,7 @@ require 'mastodon/cli/media'
describe Mastodon::CLI::Media do
let(:cli) { described_class.new }
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe '#remove' do
context 'with --prune-profiles and --remove-headers' do

@ -6,11 +6,7 @@ require 'mastodon/cli/preview_cards'
describe Mastodon::CLI::PreviewCards do
let(:cli) { described_class.new }
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe '#remove' do
context 'with relevant preview cards' do

@ -4,9 +4,5 @@ require 'rails_helper'
require 'mastodon/cli/search'
describe Mastodon::CLI::Search do
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
end

@ -4,11 +4,7 @@ require 'rails_helper'
require 'mastodon/cli/settings'
describe Mastodon::CLI::Settings do
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe 'subcommand "registrations"' do
let(:cli) { Mastodon::CLI::Registrations.new }

@ -6,11 +6,7 @@ require 'mastodon/cli/statuses'
describe Mastodon::CLI::Statuses do
let(:cli) { described_class.new }
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe '#remove', use_transactional_tests: false do
context 'with small batch size' do

@ -4,9 +4,5 @@ require 'rails_helper'
require 'mastodon/cli/upgrade'
describe Mastodon::CLI::Upgrade do
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
end

@ -0,0 +1,11 @@
# frozen_string_literal: true
shared_examples 'CLI Command' do
it 'configures Thor to exit on failure' do
expect(described_class.exit_on_failure?).to be true
end
it 'descends from the CLI base class' do
expect(described_class.new).to be_a(Mastodon::CLI::Base)
end
end
Loading…
Cancel
Save