Formalize some patterns in cli specs (#28255)
This commit is contained in:
parent
5d97a897c8
commit
ad34d33bfd
17 changed files with 492 additions and 449 deletions
|
@ -4,20 +4,25 @@ require 'rails_helper'
|
|||
require 'mastodon/cli/feeds'
|
||||
|
||||
describe Mastodon::CLI::Feeds do
|
||||
subject { cli.invoke(action, arguments, options) }
|
||||
|
||||
let(:cli) { described_class.new }
|
||||
let(:arguments) { [] }
|
||||
let(:options) { {} }
|
||||
|
||||
it_behaves_like 'CLI Command'
|
||||
|
||||
describe '#build' do
|
||||
let(:action) { :build }
|
||||
|
||||
before { Fabricate(:account) }
|
||||
|
||||
context 'with --all option' do
|
||||
let(:options) { { all: true } }
|
||||
|
||||
it 'regenerates feeds for all accounts' do
|
||||
expect { cli.invoke(:build, [], options) }.to output(
|
||||
a_string_including('Regenerated feeds')
|
||||
).to_stdout
|
||||
expect { subject }
|
||||
.to output_results('Regenerated feeds')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -27,9 +32,8 @@ describe Mastodon::CLI::Feeds do
|
|||
let(:arguments) { ['alice'] }
|
||||
|
||||
it 'regenerates feeds for the account' do
|
||||
expect { cli.invoke(:build, arguments) }.to output(
|
||||
a_string_including('OK')
|
||||
).to_stdout
|
||||
expect { subject }
|
||||
.to output_results('OK')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -37,22 +41,23 @@ describe Mastodon::CLI::Feeds do
|
|||
let(:arguments) { ['invalid-username'] }
|
||||
|
||||
it 'displays an error and exits' do
|
||||
expect { cli.invoke(:build, arguments) }.to output(
|
||||
a_string_including('No such account')
|
||||
).to_stdout.and raise_error(SystemExit)
|
||||
expect { subject }
|
||||
.to output_results('No such account')
|
||||
.and raise_error(SystemExit)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#clear' do
|
||||
let(:action) { :clear }
|
||||
|
||||
before do
|
||||
allow(redis).to receive(:del).with(key_namespace)
|
||||
end
|
||||
|
||||
it 'clears the redis `feed:*` namespace' do
|
||||
expect { cli.invoke(:clear) }.to output(
|
||||
a_string_including('OK')
|
||||
).to_stdout
|
||||
expect { subject }
|
||||
.to output_results('OK')
|
||||
|
||||
expect(redis).to have_received(:del).with(key_namespace).once
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue