spec/integration/text_field/spec.rb in pdf_ravager-0.1.0 vs spec/integration/text_field/spec.rb in pdf_ravager-0.2.0
- old
+ new
@@ -1,20 +1,19 @@
-require 'integration/integration_helper'
+require File.dirname(__FILE__) + '/../integration_helper'
describe 'a PDF with a text field' do
- describe 'filled with foo' do
- before(:each) do
- p = PDFRavager::Template.new do |t|
+ let(:input_pdf) { File.join(File.dirname(__FILE__), "pdf") }
+
+ context 'filled with foo' do
+ let(:template) {
+ PDFRavager::Template.new do |t|
t.text 'text_field', 'foo'
end
- pdf_file = File.join(File.dirname(__FILE__), "pdf")
- @pdf_file = mktemp('.pdf')
- @pdf = p.ravage pdf_file, :out_file => @pdf_file
- end
+ }
+ let(:expected) { File.join(File.dirname(__FILE__), "expected.png") }
- it 'should match expected.png when rendered' do
- png = pdf_to_png(@pdf_file)
- pix_diff, pct_diff = png_diff(png, File.join(File.dirname(__FILE__), "expected.png"))
- pix_diff.should be 0
+ it 'matches expected.png when rendered' do
+ pix_diff, _ = compare_pdf_to_png(ravage_to_temp_file(template, input_pdf), expected)
+ expect(pix_diff).to eq(0)
end
end
end