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,42 +4,45 @@ require 'rails_helper'
require 'mastodon/cli/canonical_email_blocks'
describe Mastodon::CLI::CanonicalEmailBlocks do
subject { cli.invoke(action, arguments, options) }
let(:cli) { described_class.new }
let(:arguments) { [] }
let(:options) { {} }
it_behaves_like 'CLI Command'
describe '#find' do
let(:action) { :find }
let(:arguments) { ['user@example.com'] }
context 'when a block is present' do
before { Fabricate(:canonical_email_block, email: 'user@example.com') }
it 'announces the presence of the block' do
expect { cli.invoke(:find, arguments) }.to output(
a_string_including('user@example.com is blocked')
).to_stdout
expect { subject }
.to output_results('user@example.com is blocked')
end
end
context 'when a block is not present' do
it 'announces the absence of the block' do
expect { cli.invoke(:find, arguments) }.to output(
a_string_including('user@example.com is not blocked')
).to_stdout
expect { subject }
.to output_results('user@example.com is not blocked')
end
end
end
describe '#remove' do
let(:action) { :remove }
let(:arguments) { ['user@example.com'] }
context 'when a block is present' do
before { Fabricate(:canonical_email_block, email: 'user@example.com') }
it 'removes the block' do
expect { cli.invoke(:remove, arguments) }.to output(
a_string_including('Unblocked user@example.com')
).to_stdout
expect { subject }
.to output_results('Unblocked user@example.com')
expect(CanonicalEmailBlock.matching_email('user@example.com')).to be_empty
end
@ -47,9 +50,8 @@ describe Mastodon::CLI::CanonicalEmailBlocks do
context 'when a block is not present' do
it 'announces the absence of the block' do
expect { cli.invoke(:remove, arguments) }.to output(
a_string_including('user@example.com is not blocked')
).to_stdout
expect { subject }
.to output_results('user@example.com is not blocked')
end
end
end