spec/pdfkit_spec.rb in pdfkit-0.8.7.2 vs spec/pdfkit_spec.rb in pdfkit-0.8.7.3
- old
+ new
@@ -43,12 +43,12 @@
pdfkit = PDFKit.new('html', :page_size => 'Letter')
expect(pdfkit.options).to have_key('--page-size')
end
it "transforms complex keys into command-line arguments" do
- pdfkit = PDFKit.new('html', :replace => {'value' => 'something else'} )
- expect(pdfkit.options).to have_key('--replace')
+ pdfkit = PDFKit.new('html', :header_left => {'value' => 'something else'} )
+ expect(pdfkit.options).to have_key('--header-left')
end
it "drops options with false or falsey values" do
pdfkit = PDFKit.new('html', disable_smart_shrinking: false)
expect(pdfkit.options).not_to have_key('--disable-smart-shrinking')
@@ -70,24 +70,24 @@
pdfkit = PDFKit.new('html', image_dpi: 300)
expect(pdfkit.options['--image-dpi']).to eql '300'
end
it "parses hash option values into an array" do
- pdfkit = PDFKit.new('html', :replace => {'value' => 'something else'} )
- expect(pdfkit.options['--replace']).to eql ['value', 'something else']
+ pdfkit = PDFKit.new('html', :header_left => {'value' => 'something else'} )
+ expect(pdfkit.options['--header-left']).to eql ['value', 'something else']
end
it "flattens hash options into the key" do
pdfkit = PDFKit.new('html', :cookie => {:cookie_name1 => :cookie_val1, :cookie_name2 => :cookie_val2})
expect(pdfkit.options).not_to have_key('--cookie')
expect(pdfkit.options[['--cookie', 'cookie_name1']]).to eql 'cookie_val1'
expect(pdfkit.options[['--cookie', 'cookie_name2']]).to eql 'cookie_val2'
end
it "parses array option values into a string" do
- pdfkit = PDFKit.new('html', :replace => ['value', 'something else'] )
- expect(pdfkit.options['--replace']).to eql ['value', 'something else']
+ pdfkit = PDFKit.new('html', :header_left => ['value', 'something else'] )
+ expect(pdfkit.options['--header-left']).to eql ['value', 'something else']
end
it "flattens array options" do
pdfkit = PDFKit.new('html', :cookie => [[:cookie_name1, :cookie_val1], [:cookie_name2, :cookie_val2]])
expect(pdfkit.options).not_to have_key('--cookie')
@@ -177,9 +177,23 @@
command = pdfkit.command
expect(command.first).to match(/wkhtmltopdf/)
expect(command).to contain %w[--page-size Letter]
expect(command).to contain %w[--toc-l1-font-size 12]
expect(command).to contain %w[--replace foo bar]
+ end
+
+ it "contains a specified by path argument" do
+ pdfkit = PDFKit.new('html')
+ command = pdfkit.command("/foo/bar")
+ expect(command.first).to match(/wkhtmltopdf/)
+ expect(command.last).to eq("/foo/bar")
+ end
+
+ it "contains a specified by path argument of Pathname" do
+ pdfkit = PDFKit.new('html')
+ command = pdfkit.command(Pathname.new("/foo/bar"))
+ expect(command.first).to match(/wkhtmltopdf/)
+ expect(command.last).to eq("/foo/bar")
end
it "sets up one cookie when hash has only one cookie" do
pdfkit = PDFKit.new('html', cookie: {cookie_name: :cookie_value})
command = pdfkit.command