1
0
mirror of https://github.com/mastodon/mastodon synced 2024-11-23 22:56:20 +09:00

Add spec coverage for CLI::Emoji class (#28182)

This commit is contained in:
Matt Jankowski 2023-12-06 03:52:30 -05:00 committed by GitHub
parent ed7b5c091b
commit 0e8ba19113
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 0 deletions

BIN
spec/fixtures/files/elite-assets.tar.gz vendored Normal file

Binary file not shown.

View File

@ -4,5 +4,59 @@ require 'rails_helper'
require 'mastodon/cli/emoji'
describe Mastodon::CLI::Emoji do
subject { cli.invoke(action, args, options) }
let(:cli) { described_class.new }
let(:args) { [] }
let(:options) { {} }
it_behaves_like 'CLI Command'
describe '#purge' do
let(:action) { :purge }
context 'with existing custom emoji' do
before { Fabricate(:custom_emoji) }
it 'reports a successful purge' do
expect { subject }
.to output_results('OK')
end
end
end
describe '#import' do
context 'with existing custom emoji' do
let(:import_path) { Rails.root.join('spec', 'fixtures', 'files', 'elite-assets.tar.gz') }
let(:action) { :import }
let(:args) { [import_path] }
it 'reports about imported emoji' do
expect { subject }
.to output_results('Imported 1')
.and change(CustomEmoji, :count).by(1)
end
end
end
describe '#export' do
context 'with existing custom emoji' do
before { Fabricate(:custom_emoji) }
after { File.delete(export_path) }
let(:export_path) { Rails.root.join('tmp', 'export.tar.gz') }
let(:args) { [Rails.root.join('tmp')] }
let(:action) { :export }
it 'reports about exported emoji' do
expect { subject }
.to output_results('Exported 1')
.and change { File.exist?(export_path) }.from(false).to(true)
end
end
end
def output_results(string)
output(a_string_including(string)).to_stdout
end
end