Sha256: 69add9421b090c96831ec4b8fb7200a80c67d8fdaaf243053b57fb35101687f0

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'
require 'pdf_ravager/pdf'

class TestPDF < MiniTest::Unit::TestCase
  def setup
    @pdf = pdf 'foo.pdf' do
      text  'text',      'foo'
      text  'rich_text', '<b>foo</b>', :rich => true
      check 'checkbox'
      checkbox_group 'checkbox_group' do
        check 'foo'
      end
      radio_group 'radio_group' do
        fill 'foo'
      end
    end

    @pdf_from_json = JSON.parse(@pdf.to_json)
  end

  def test_that_name_is_set
    assert_equal @pdf.name, 'foo.pdf'
  end

  def test_that_text_is_set
    assert_includes @pdf.fields, {:name => 'text', :value => 'foo', :type => :text}
  end

  def test_that_rich_text_is_set
    assert_includes @pdf.fields, {:name => 'rich_text', :value => '<b>foo</b>', :type => :text, :options => {:rich => true}}
  end

  def test_that_checkbox_is_set
    assert_includes @pdf.fields, {:name => 'checkbox', :value => true, :type => :checkbox}
  end

  def test_that_checkbox_group_is_set
    assert_includes @pdf.fields, {:name => 'checkbox_group.foo', :value => true, :type => :checkbox}
  end

  def test_that_radio_group_is_set
    assert_includes @pdf.fields, {:name => 'radio_group', :value => 'foo', :type => :radio}
  end

  def test_json_serialization
    assert_equal @pdf, @pdf_from_json
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pdf_ravager-0.0.7 spec/pdf_spec.rb
pdf_ravager-0.0.6-java spec/pdf_spec.rb