CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/spec/lib/rex/time_spec.rb
Views: 11777
1
# -*- coding:binary -*-
2
require 'spec_helper'
3
4
5
RSpec.describe Rex::ExtTime do
6
7
let(:conversions) do
8
{
9
0 => '0 secs',
10
1 => '1 sec',
11
60 => '1 min',
12
61 => '1 min 1 sec',
13
121 => '2 mins 1 sec',
14
3600 => '1 hour',
15
3660 => '1 hour 1 min',
16
3661 => '1 hour 1 min 1 sec',
17
7326 => '2 hours 2 mins 6 secs',
18
86400 => '1 day',
19
86401 => '1 day 1 sec',
20
86460 => '1 day 1 min',
21
86461 => '1 day 1 min 1 sec',
22
90000 => '1 day 1 hour',
23
90060 => '1 day 1 hour 1 min',
24
90125 => '1 day 1 hour 2 mins 5 secs',
25
31536000 => '1 year',
26
31536003 => '1 year 3 secs',
27
31536063 => '1 year 1 min 3 secs',
28
31539600 => '1 year 1 hour',
29
31622400 => '1 year 1 day',
30
31626000 => '1 year 1 day 1 hour',
31
31626001 => '1 year 1 day 1 hour 1 sec',
32
31626060 => '1 year 1 day 1 hour 1 min',
33
31626061 => '1 year 1 day 1 hour 1 min 1 sec'
34
}
35
end
36
37
subject { described_class }
38
39
describe ".sec_to_s" do
40
it "returns string encoded seconds" do
41
conversions.each do |k, v|
42
expect(subject.sec_to_s(k)).to eq(v)
43
end
44
end
45
end
46
end
47
48