Skip to content

Commit e0e348a

Browse files
committed
Specs to ensure File.mtime error is caught.
[#47720609]
1 parent 541d287 commit e0e348a

File tree

1 file changed

+49
-29
lines changed
  • spec/support/shared/examples/msf/module_manager

1 file changed

+49
-29
lines changed

spec/support/shared/examples/msf/module_manager/cache.rb

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -80,47 +80,67 @@ def module_info_by_path
8080
mock('Msf::Modules::Namespace', :parent_path => parent_path)
8181
end
8282

83-
it 'should update module_info_by_path' do
84-
expect {
85-
cache_in_memory
86-
}.to change { module_info_by_path }
87-
end
88-
89-
context 'module_info_by_path' do
90-
subject(:module_info_by_path) do
91-
module_manager.send(:module_info_by_path)
92-
end
93-
94-
before(:each) do
95-
cache_in_memory
96-
end
97-
98-
it 'should have entry for path' do
99-
module_info_by_path[path].should be_a Hash
83+
context 'with existing :path' do
84+
it 'should update module_info_by_path' do
85+
expect {
86+
cache_in_memory
87+
}.to change { module_info_by_path }
10088
end
10189

102-
context 'value' do
103-
subject(:value) do
104-
module_info_by_path[path]
90+
context 'module_info_by_path' do
91+
subject(:module_info_by_path) do
92+
module_manager.send(:module_info_by_path)
10593
end
10694

107-
it 'should have modification time of :path option for :modification_time' do
108-
value[:modification_time].should == pathname_modification_time
95+
before(:each) do
96+
cache_in_memory
10997
end
11098

111-
it 'should have parent path from namespace module for :parent_path' do
112-
value[:parent_path].should == namespace_module.parent_path
99+
it 'should have entry for path' do
100+
module_info_by_path[path].should be_a Hash
113101
end
114102

115-
it 'should use :reference_name option' do
116-
value[:reference_name].should == reference_name
117-
end
103+
context 'value' do
104+
subject(:value) do
105+
module_info_by_path[path]
106+
end
107+
108+
it 'should have modification time of :path option for :modification_time' do
109+
value[:modification_time].should == pathname_modification_time
110+
end
118111

119-
it 'should use :type option' do
120-
value[:type].should == type
112+
it 'should have parent path from namespace module for :parent_path' do
113+
value[:parent_path].should == namespace_module.parent_path
114+
end
115+
116+
it 'should use :reference_name option' do
117+
value[:reference_name].should == reference_name
118+
end
119+
120+
it 'should use :type option' do
121+
value[:type].should == type
122+
end
121123
end
122124
end
123125
end
126+
127+
context 'without existing :path' do
128+
let(:path) do
129+
'non/existent/path'
130+
end
131+
132+
it 'should not raise error' do
133+
expect {
134+
cache_in_memory
135+
}.to_not raise_error
136+
end
137+
138+
it 'should not update module_info_by_path' do
139+
expect {
140+
cache_in_memory
141+
}.to_not change { module_info_by_path }
142+
end
143+
end
124144
end
125145

126146
context '#load_cached_module' do

0 commit comments

Comments
 (0)