diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2020-05-21 23:58:42 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2020-05-22 00:05:01 -0600 |
| commit | daf2340f91574fadccf59e0514f29cb8ad8f2564 (patch) | |
| tree | 9cd0a0de9ada323413f0207e23fd5332825ff7f7 /spec/page_spec.rb | |
| parent | 080f871317d81d0d6dbdebc1c0724b09396770cf (diff) | |
allow page size value to be a symbol; add test for invalid type
Diffstat (limited to 'spec/page_spec.rb')
| -rw-r--r-- | spec/page_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/page_spec.rb b/spec/page_spec.rb index 4e11adff..c729dee4 100644 --- a/spec/page_spec.rb +++ b/spec/page_spec.rb @@ -12,6 +12,16 @@ describe 'Asciidoctor::PDF::Converter - Page' do (expect pdf.pages[0][:size]).to eql PDF::Core::PageGeometry::SIZES['A4'] end + it 'should set page size specified by page_size key in theme with predefined name' do + ['LEGAL', 'legal', :LEGAL, :legal].each do |page_size| + pdf = to_pdf <<~'EOS', pdf_theme: { page_size: page_size }, analyze: :page + content + EOS + (expect pdf.pages).to have_size 1 + (expect pdf.pages[0][:size].map(&:to_f)).to eql PDF::Core::PageGeometry::SIZES['LEGAL'] + end + end + it 'should set page size specified by pdf-page-size attribute using predefined name' do pdf = to_pdf <<~'EOS', analyze: :page :pdf-page-size: Letter @@ -75,6 +85,14 @@ describe 'Asciidoctor::PDF::Converter - Page' do (expect pdf.pages[0][:size].map(&:to_f)).to eql PDF::Core::PageGeometry::SIZES['A4'] end + it 'should use default page size if page size has unrecognized type' do + pdf = to_pdf <<~'EOS', pdf_theme: { page_size: true }, analyze: :page + content + EOS + (expect pdf.pages).to have_size 1 + (expect pdf.pages[0][:size].map(&:to_f)).to eql PDF::Core::PageGeometry::SIZES['A4'] + end + it 'should use default page size if one of dimensions in page size array is 0' do [[800, 0], ['8.5in', '0in']].each do |page_size| pdf = to_pdf <<~'EOS', pdf_theme: { page_size: page_size }, analyze: :page |
