Skip to content

Commit

Permalink
Raise exception for unrecognized join styles
Browse files Browse the repository at this point in the history
  • Loading branch information
midpackrunner committed Oct 13, 2016
1 parent 921f398 commit 5e2ea07
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/prawn/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,8 @@ module Errors
# Raised when unrecognized content is provided for a table cell.
#
UnrecognizedTableContent = Class.new(StandardError)

# This error is raised when an incompatible join style is specified
InvalidJoinStyle = Class.new(StandardError)
end
end
5 changes: 5 additions & 0 deletions lib/prawn/graphics/join_style.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ def join_style(style = nil)

self.current_join_style = style

unless JOIN_STYLES.has_key?(current_join_style)
raise Prawn::Errors::InvalidJoinStyle,
"#{style} is not a recognized join style. Valid styles are #{JOIN_STYLES.keys.join(", ")}"
end

write_stroke_join_style
end

Expand Down
6 changes: 6 additions & 0 deletions spec/stroke_styles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
expect(join_styles.join_style_count).to eq(2)
expect(join_styles.join_style).to eq(1)
end

context "with invalid arguments" do
it "should raise an exception" do
expect{ @pdf.join_style(:mitre) }.to raise_error(Prawn::Errors::InvalidJoinStyle)
end
end
end

describe "Dashes" do
Expand Down

0 comments on commit 5e2ea07

Please sign in to comment.