|
32 | 32 | Msf::Framework.new
|
33 | 33 | end
|
34 | 34 |
|
35 |
| - subject do |
| 35 | + subject(:module_manager) do |
36 | 36 | described_class.new(framework)
|
37 | 37 | end
|
38 | 38 |
|
39 |
| - context '#add_module_path' do |
40 |
| - it 'should strip trailing File::SEPARATOR from the path' do |
41 |
| - Dir.mktmpdir do |path| |
42 |
| - path_with_trailing_separator = path + File::SEPARATOR |
43 |
| - subject.add_module_path(path_with_trailing_separator) |
44 |
| - |
45 |
| - subject.send(:module_paths).should_not include(path_with_trailing_separator) |
46 |
| - subject.send(:module_paths).should include(path) |
47 |
| - end |
48 |
| - end |
49 |
| - |
50 |
| - context 'with Fastlib archive' do |
51 |
| - it 'should raise an ArgumentError unless the File exists' do |
52 |
| - file = Tempfile.new(archive_basename) |
53 |
| - # unlink will clear path, so copy it to a variable |
54 |
| - path = file.path |
55 |
| - file.unlink |
56 |
| - |
57 |
| - File.exist?(path).should be_false |
58 |
| - |
59 |
| - expect { |
60 |
| - subject.add_module_path(path) |
61 |
| - }.to raise_error(ArgumentError, "The path supplied does not exist") |
62 |
| - end |
63 |
| - |
64 |
| - it 'should add the path to #module_paths if the File exists' do |
65 |
| - Tempfile.open(archive_basename) do |temporary_file| |
66 |
| - path = temporary_file.path |
67 |
| - |
68 |
| - File.exist?(path).should be_true |
69 |
| - |
70 |
| - subject.add_module_path(path) |
71 |
| - |
72 |
| - subject.send(:module_paths).should include(path) |
73 |
| - end |
74 |
| - end |
75 |
| - end |
76 |
| - |
77 |
| - context 'with directory' do |
78 |
| - it 'should add path to #module_paths' do |
79 |
| - Dir.mktmpdir do |path| |
80 |
| - subject.add_module_path(path) |
81 |
| - |
82 |
| - subject.send(:module_paths).should include(path) |
83 |
| - end |
84 |
| - end |
85 |
| - |
86 |
| - context 'containing Fastlib archives' do |
87 |
| - it 'should add each Fastlib archive to #module_paths' do |
88 |
| - Dir.mktmpdir do |directory| |
89 |
| - Tempfile.open(archive_basename, directory) do |file| |
90 |
| - subject.add_module_path(directory) |
91 |
| - |
92 |
| - subject.send(:module_paths).should include(directory) |
93 |
| - subject.send(:module_paths).should include(file.path) |
94 |
| - end |
95 |
| - end |
96 |
| - end |
97 |
| - end |
98 |
| - end |
99 |
| - |
100 |
| - context 'with other file' do |
101 |
| - it 'should raise ArgumentError' do |
102 |
| - Tempfile.open(basename_prefix) do |file| |
103 |
| - expect { |
104 |
| - subject.add_module_path(file.path) |
105 |
| - }.to raise_error(ArgumentError, 'The path supplied is not a valid directory.') |
106 |
| - end |
107 |
| - end |
108 |
| - end |
109 |
| - end |
| 39 | + it_should_behave_like 'Msf::ModuleManager::ModulePaths' |
110 | 40 |
|
111 | 41 | context '#file_changed?' do
|
112 | 42 | let(:module_basename) do
|
|
0 commit comments