From 8d8ae05a186bb8a5fca719dc6ea5a057d1aa197f Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 7 Dec 2023 10:27:41 -0500 Subject: [PATCH] Add spec coverage for `CLI::Media#lookup` command (#28266) --- spec/lib/mastodon/cli/media_spec.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spec/lib/mastodon/cli/media_spec.rb b/spec/lib/mastodon/cli/media_spec.rb index 6bbe7e746..24e1467a3 100644 --- a/spec/lib/mastodon/cli/media_spec.rb +++ b/spec/lib/mastodon/cli/media_spec.rb @@ -89,6 +89,32 @@ describe Mastodon::CLI::Media do end end + describe '#lookup' do + let(:action) { :lookup } + let(:arguments) { [url] } + + context 'with valid url not connected to a record' do + let(:url) { 'https://example.host/assets/1' } + + it 'warns about url and exits' do + expect { subject } + .to output_results('Not a media URL') + .and raise_error(SystemExit) + end + end + + context 'with a valid media url' do + let(:status) { Fabricate(:status) } + let(:media_attachment) { Fabricate(:media_attachment, status: status) } + let(:url) { media_attachment.file.url(:original) } + + it 'displays the url of a connected status' do + expect { subject } + .to output_results(status.id.to_s) + end + end + end + describe '#refresh' do let(:action) { :refresh }