spec/text_at_spec.rb in prawn-0.11.1.pre vs spec/text_at_spec.rb in prawn-0.11.1

- old
+ new

@@ -11,10 +11,16 @@ it "should raise ArgumentError if :align option included" do lambda { @pdf.draw_text("hai", :at => [0, 0], :align => :center) }.should.raise(ArgumentError) end + it "should allow drawing empty strings to the page" do + @pdf.draw_text(" ", :at => [100,100]) + text = PDF::Inspector::Text.analyze(@pdf.render) + text.strings.first.should == " " + end + it "should default to 12 point helvetica" do @pdf.draw_text("Blah", :at => [100,100]) text = PDF::Inspector::Text.analyze(@pdf.render) text.font_settings[0][:name].should == :Helvetica text.font_settings[0][:size].should == 12 @@ -95,25 +101,29 @@ if "spec".respond_to?(:encode!) # Handle non utf-8 string encodings in a sane way on M17N aware VMs it "should raise an exception when a utf-8 incompatible string is rendered" do str = "Blah \xDD" str.force_encoding("ASCII-8BIT") - lambda { @pdf.draw_text(str, :at => [0, 0]) }.should.raise(ArgumentError) + lambda { @pdf.draw_text(str, :at => [0, 0]) }.should.raise( + Prawn::Errors::IncompatibleStringEncoding) end it "should not raise an exception when a shift-jis string is rendered" do datafile = "#{Prawn::BASEDIR}/data/shift_jis_text.txt" sjis_str = File.open(datafile, "r:shift_jis") { |f| f.gets } @pdf.font("#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf") - lambda { @pdf.draw_text(sjis_str, :at => [0, 0]) }.should.not.raise(ArgumentError) + lambda { @pdf.draw_text(sjis_str, :at => [0, 0]) }.should.not.raise( + Prawn::Errors::IncompatibleStringEncoding) end else # Handle non utf-8 string encodings in a sane way on non-M17N aware VMs it "should raise an exception when a corrupt utf-8 string is rendered" do str = "Blah \xDD" - lambda { @pdf.draw_text(str, :at => [0, 0]) }.should.raise(ArgumentError) + lambda { @pdf.draw_text(str, :at => [0, 0]) }.should.raise( + Prawn::Errors::IncompatibleStringEncoding) end it "should raise an exception when a shift-jis string is rendered" do sjis_str = File.read("#{Prawn::BASEDIR}/data/shift_jis_text.txt") - lambda { @pdf.draw_text(sjis_str, :at => [0, 0]) }.should.raise(ArgumentError) + lambda { @pdf.draw_text(sjis_str, :at => [0, 0]) }.should.raise( + Prawn::Errors::IncompatibleStringEncoding) end end end