Skip to content

Add spec for Remove #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions spec/cli/commands/remove_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,31 @@

describe Ronin::Wordlists::CLI::Commands::Remove do
include_examples "man_page"

let(:wordlist_dir) { double('WordlistDir') }

describe '#run' do
context 'when the wordlist exists' do
let(:wordlist_name) { 'wordlist' }

before do
allow(subject).to receive(:wordlist_dir).and_return(wordlist_dir)
end

it 'must remove it from cache directory' do
expect(wordlist_dir).to receive(:remove).with(wordlist_name)
subject.run(wordlist_name)
end
end

context 'when the wordlist does not exist' do
let(:wordlist_name) { 'not_existing_wordlist' }

it 'must print an error message and exit' do
expect {
subject.run(wordlist_name)
}.to output(/no such wordlist: #{wordlist_name}/).to_stderr.and raise_error(SystemExit)
end
end
end
end