Skip to content

Commit

Permalink
Add spec for Fugit.parse() and .do_parse, gh-104
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed Aug 15, 2024
1 parent 025ad7b commit 767ef55
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions spec/parse_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@

it "returns nil quickly if the input is useless and long, gh-104" do

o = Fugit.parse('0 0' + ' 0' * 10_000 + ' 1 jan * UTC')
p o
# TODO
o, d = do_time {
Fugit.parse('0 0' + ' 0' * 10_000 + ' 1 jan * UTC') }

expect(o).to be(nil)
expect(d).to be < 0.042
end
end

Expand All @@ -142,6 +144,23 @@
expect { Fugit.do_parse(k) }.to raise_error(ArgumentError)
end
end

it "fails quickly if the input is useless and long, gh-104" do

r, d = do_time {
begin
Fugit.do_parse('0 0' + ' 0' * 10_000 + ' 1 jan * UTC')
rescue => err
err
end }

expect(r.class).to be(
ArgumentError)
expect(r.message).to eq(
'invalid cron string "0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... len 20015"')

expect(d).to be < 0.042
end
end

CRONISHES = {
Expand Down

0 comments on commit 767ef55

Please sign in to comment.