Skip to content

Commit

Permalink
Raise RuntimeError when try convert from unspported class
Browse files Browse the repository at this point in the history
  • Loading branch information
atton committed Sep 22, 2017
1 parent 141a28a commit b645e22
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/rghost/ruby_ghost_engine.rb
Expand Up @@ -67,6 +67,8 @@ def render(device=nil)
#@delete_input=false unless @options[:debug]
when String
file_in=@document
else
raise RuntimeError.new("Cannot convert #{@document.class}. Supported classes are RGhost::Document or File or String.")
end

params << shellescape(file_in)
Expand Down
4 changes: 2 additions & 2 deletions spec/color_spec.rb
Expand Up @@ -143,7 +143,7 @@

it "should create a color from a hex(html style)" do
c = RGhost::RGB.new "#ABBACA"
c.ps.to_s.should == "0.670588235294118 0.729411764705882 0.792156862745098 setrgbcolor"
c.ps.to_s.should == "0.6705882352941176 0.7294117647058823 0.792156862745098 setrgbcolor"

c = RGhost::RGB.new "#FFFFFF"
c.ps.to_s.should == "1.0 1.0 1.0 setrgbcolor"
Expand All @@ -158,7 +158,7 @@
c.ps.to_s.should == "1.0 1.0 0.0 setrgbcolor"

c = RGhost::RGB.new "#334455"
c.ps.to_s.should == "0.2 0.266666666666667 0.333333333333333 setrgbcolor"
c.ps.to_s.should == "0.2 0.26666666666666666 0.3333333333333333 setrgbcolor"

end

Expand Down
4 changes: 4 additions & 0 deletions spec/convert_spec.rb
Expand Up @@ -45,6 +45,10 @@
File.size(file).should_not be(0)

end

it "should raise exception when initialize with not supported file" do
expect{ RGhost::Convert.new(nil).to :jpeg }.to raise_error(/NilClass/)
end



Expand Down
2 changes: 1 addition & 1 deletion spec/document_spec.rb
Expand Up @@ -6,7 +6,7 @@

doc = RGhost::Document.new
r = doc.render :pdf, :filename => RGhost.using_temp_dir("testdoc.pdf")
File.exists?(r.output).should be_true
File.exists?(r.output).should be true

end

Expand Down

0 comments on commit b645e22

Please sign in to comment.