Skip to content

Commit 3bf3cfc

Browse files
committed
Use be_within to loosen tolerance for Time comparisons
[#47979793] [#48414569] Even though using Timecop locally on OS X makes the `should == <Time>` work, it fails on travis-ci, so try using `should be_within(1.second).of(<Time>)` instead.
1 parent e5befb7 commit 3bf3cfc

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

spec/lib/msf/core/db_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@
287287

288288
its(:host) { should == Mdm::Host.last }
289289
its(:refs) { should == [] }
290-
its(:exploited_at) { should == Time.now.utc }
290+
its(:exploited_at) { should be_within(1.second).of(Time.now.utc) }
291291

292292
context "with session.via_exploit 'exploit/multi/handler'" do
293293
context "with session.exploit_datastore['ParentModule']" do
@@ -374,7 +374,7 @@
374374
Mdm::ExploitAttempt.last
375375
end
376376

377-
its(:attempted_at) { should == Time.now.utc }
377+
its(:attempted_at) { should be_within(1.second).of(Time.now.utc) }
378378
# @todo https://www.pivotaltracker.com/story/show/48362615
379379
its(:session_id) { should == Mdm::Session.last.id }
380380
its(:exploited) { should == true }
@@ -442,9 +442,9 @@
442442
its(:datastore) { should == session.exploit_datastore.to_h }
443443
its(:desc) { should == session.info }
444444
its(:host_id) { should == Mdm::Host.last.id }
445-
its(:last_seen) { should == Time.now.utc }
445+
its(:last_seen) { should be_within(1.second).of(Time.now.utc) }
446446
its(:local_id) { should == session.sid }
447-
its(:opened_at) { should == Time.now.utc }
447+
its(:opened_at) { should be_within(1.second).of(Time.now.utc) }
448448
its(:platform) { should == session.platform }
449449
its(:routes) { should == [] }
450450
its(:stype) { should == session.type }

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ def module_info_by_path_from_database!
303303
)
304304
end
305305

306+
let(:pathname_modification_time) do
307+
pathname.mtime
308+
end
309+
306310
let(:type) do
307311
'exploit'
308312
end
@@ -345,7 +349,7 @@ def module_info_by_path_from_database!
345349
module_info_by_path_from_database!
346350
end
347351

348-
its([:modification_time]) { should == pathname.mtime }
352+
its([:modification_time]) { should be_within(1.second).of(pathname_modification_time) }
349353
its([:parent_path]) { should == parent_path }
350354
its([:reference_name]) { should == reference_name }
351355
its([:type]) { should == type }

0 commit comments

Comments
 (0)