Skip to content

Commit 55a2294

Browse files
John Crepezziseejohnrun
authored andcommitted
Raise an ArgumentError if given an empty ical string
1 parent 04d81c5 commit 55a2294

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/ice_cube/parsers/ical_parser.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ def self.schedule_from_ical(ical_string, options = {})
2424
end
2525

2626
def self.rule_from_ical(ical)
27+
raise ArgumentError, 'empty ical rule' if ical.nil?
28+
2729
validations = {}
2830
params = {validations: validations, interval: 1}
2931

spec/examples/from_ical_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,21 @@ def sorted_ical(ical)
385385
schedule.recurrence_rules.count.should == 2
386386
end
387387
end
388+
389+
describe 'invalid ical data' do
390+
shared_examples_for('an invalid ical string') do
391+
it do
392+
expect {
393+
IceCube::Schedule.from_ical(ical_str)
394+
}.to raise_error(ArgumentError) # TODO replace with real ad
395+
end
396+
end
397+
398+
describe 'empty rules' do
399+
let(:ical_str) { 'RRULE::' }
400+
it_behaves_like 'an invalid ical string'
401+
end
402+
end
388403
end
389404

390405
end

0 commit comments

Comments
 (0)