Skip to content

Commit bcd8d83

Browse files
authored
Add specs for WorlistDirOption (#21)
1 parent 9ed3aa9 commit bcd8d83

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

spec/cli/wordlist_dir_option_spec.rb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
require 'spec_helper'
2+
require 'ronin/wordlists/cli/wordlist_dir_option'
3+
require 'ronin/wordlists/cli/command'
4+
5+
RSpec.describe Ronin::Wordlists::CLI::WordlistDirOption do
6+
class TestWordlistDirOptionCommand < Ronin::Wordlists::CLI::Command
7+
include Ronin::Wordlists::CLI::WordlistDirOption
8+
end
9+
10+
let(:command_class) { TestWordlistDirOptionCommand }
11+
12+
describe '.included' do
13+
subject { command_class }
14+
15+
it 'adds the --wordlist-dir option to the command' do
16+
expect(subject.options).to include(:wordlist_dir)
17+
end
18+
end
19+
20+
describe '#wordlist_dir' do
21+
subject { command_class.new }
22+
23+
context 'when --wordlist-dir is specified' do
24+
before do
25+
subject.options[:wordlist_dir] = '/path/to/dir'
26+
end
27+
28+
it 'returns a WordlistDir with the specified directory' do
29+
expect(subject.wordlist_dir).to be_a(Ronin::Wordlists::WordlistDir)
30+
expect(subject.wordlist_dir.path).to eq('/path/to/dir')
31+
end
32+
end
33+
34+
context 'when --wordlist-dir is not specified' do
35+
it 'returns a default CacheDir' do
36+
expect(subject.wordlist_dir).to be_a(Ronin::Wordlists::CacheDir)
37+
end
38+
end
39+
end
40+
end

0 commit comments

Comments
 (0)