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

@ -7,59 +7,64 @@ describe Mastodon::CLI::Settings do
it_behaves_like 'CLI Command'
describe 'subcommand "registrations"' do
subject { cli.invoke(action, arguments, options) }
let(:cli) { Mastodon::CLI::Registrations.new }
let(:arguments) { [] }
let(:options) { {} }
before do
Setting.registrations_mode = nil
end
describe '#open' do
let(:action) { :open }
it 'changes "registrations_mode" to "open"' do
expect { cli.open }.to change(Setting, :registrations_mode).from(nil).to('open')
expect { subject }.to change(Setting, :registrations_mode).from(nil).to('open')
end
it 'displays success message' do
expect { cli.open }.to output(
a_string_including('OK')
).to_stdout
expect { subject }
.to output_results('OK')
end
end
describe '#approved' do
let(:action) { :approved }
it 'changes "registrations_mode" to "approved"' do
expect { cli.approved }.to change(Setting, :registrations_mode).from(nil).to('approved')
expect { subject }.to change(Setting, :registrations_mode).from(nil).to('approved')
end
it 'displays success message' do
expect { cli.approved }.to output(
a_string_including('OK')
).to_stdout
expect { subject }
.to output_results('OK')
end
context 'with --require-reason' do
before do
cli.options = { require_reason: true }
end
let(:options) { { require_reason: true } }
it 'changes "registrations_mode" to "approved"' do
expect { cli.approved }.to change(Setting, :registrations_mode).from(nil).to('approved')
expect { subject }.to change(Setting, :registrations_mode).from(nil).to('approved')
end
it 'sets "require_invite_text" to "true"' do
expect { cli.approved }.to change(Setting, :require_invite_text).from(false).to(true)
expect { subject }.to change(Setting, :require_invite_text).from(false).to(true)
end
end
end
describe '#close' do
let(:action) { :close }
it 'changes "registrations_mode" to "none"' do
expect { cli.close }.to change(Setting, :registrations_mode).from(nil).to('none')
expect { subject }.to change(Setting, :registrations_mode).from(nil).to('none')
end
it 'displays success message' do
expect { cli.close }.to output(
a_string_including('OK')
).to_stdout
expect { subject }
.to output_results('OK')
end
end
end