Skip to content

Commit

Permalink
rspec reporting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Sep 23, 2017
1 parent 407489d commit e44ff7e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/vobject_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ def norm_vcard(ics)
gsub(/;TYPE="([^"]+)"/, ";TYPE=\\1").split("\n").sort.join("\n")
end

RSpec::Matchers.define :contain_error do |expected|
match do |actual|
actual.select { |a| a =~ expected }
end
end

# rubocop:disable LineLength
describe Vobject do
it "should process RFC6868 caret parameters" do
Expand Down Expand Up @@ -209,6 +215,10 @@ def norm_vcard(ics)
ics = File.read "spec/examples/vcalendar/base64.ics"
expect { Vcalendar.parse(ics, true) }.to raise_error(/Malformed binary coding for property ATTACH/)
end
it "should report errors on proper Bin64 encoding" do
ics = File.read "spec/examples/vcalendar/base64.ics"
expect(Vcalendar.parse(ics, false).get_errors).to contain_error(/Malformed binary coding for property ATTACH/)
end

it "should parse iCalendar properly with blank description" do
ics = File.read "spec/examples/vcalendar/blank_description.ics"
Expand All @@ -232,6 +242,10 @@ def norm_vcard(ics)
ics = File.read "spec/examples/vcalendar/blank_line_end.ics"
expect { Vcalendar.parse(ics, true) }.to raise_error(Rsec::SyntaxError)
end
it "should require at least one component" do
ics = File.read "spec/examples/vcalendar/blank_line_end.ics"
expect(Vcalendar.parse(ics, false).get_errors).to contain_error(/SyntaxError/)
end

it "should reject blank lines" do
ics = File.read "spec/examples/vcalendar/blank_line_mid.ics"
Expand Down

0 comments on commit e44ff7e

Please sign in to comment.