Skip to content

Commit

Permalink
add time parsing test
Browse files Browse the repository at this point in the history
  • Loading branch information
zgoldman-r7 committed Oct 11, 2023
1 parent 48f28f0 commit ac7341b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
12 changes: 11 additions & 1 deletion spec/lib/msf/ui/console/command_dispatcher/core_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,16 @@ def set_tabs_test(option)
end

describe "#parse_duration" do

expected_values = {
"1s" => 1,
"2s" => 2,
"1.5m" => 90,
"1.5d" => 129600,
"1d1h1m1s" => 90061,
"1.5d1.5h1.5m1.5s" => 135091,
"1.75m70s" => 175
}

it_behaves_like "parses time values correctly", expected_values
end
end
9 changes: 9 additions & 0 deletions spec/support/shared/examples/parse_duration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding:binary -*-

RSpec.shared_examples_for "parses time values correctly" do |expected_values|
it "returns expected values" do
expected_values.each do |input, output|
expect(core.parse_duration(input)).to eq(output)
end
end
end

0 comments on commit ac7341b

Please sign in to comment.