diff --git a/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb b/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb index ad49a775f23cc..2c9b08f00fab6 100644 --- a/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb +++ b/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb @@ -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 diff --git a/spec/support/shared/examples/parse_duration.rb b/spec/support/shared/examples/parse_duration.rb new file mode 100644 index 0000000000000..0ceb65752e44f --- /dev/null +++ b/spec/support/shared/examples/parse_duration.rb @@ -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