Sha256: fa229eba26ccb340d9b65c607c076d0cc0d7a6f37472dbf51229309416341f80
Contents?: true
Size: 1.82 KB
Versions: 3
Compression:
Stored size: 1.82 KB
Contents
# -*- encoding: utf-8 -*- require 'test_helper' require_relative '../content/common' require 'hexapdf/document' require 'hexapdf/type/form' describe HexaPDF::Type::Form do before do @doc = HexaPDF::Document.new @form = @doc.wrap({}, subtype: :Form) end describe "box" do it "returns the /BBox entry" do @form[:BBox] = :media assert_equal(:media, @form.box) end end describe "contents" do it "returns a duplicate of the stream" do @form.stream = 'test' assert_equal(@form.stream, @form.contents) @form.contents.gsub!(/test/, 'other') assert_equal(@form.stream, @form.contents) end end describe "contents=" do it "set the stream contents" do @form.contents = 'test' assert_equal('test', @form.stream) end end describe "resources" do it "creates the resource dictionary if it is not found" do resources = @form.resources assert_equal(:XXResources, resources.type) assert_equal({}, resources.value) end it "returns the already used resource dictionary" do @form[:Resources] = {Font: nil} resources = @form.resources assert_equal(:XXResources, resources.type) assert_equal(@form[:Resources], resources) end end describe "process_contents" do it "parses the contents and processes it" do @form.stream = '10 w' processor = TestHelper::OperatorRecorder.new @form.process_contents(processor) assert_equal([[:set_line_width, [10]]], processor.recorded_ops) end end describe "canvas" do it "always returns the same Canvas instance" do canvas = @form.canvas assert_same(canvas, @form.canvas) end it "fails if the form XObject already has data" do @form.stream = '10 w' assert_raises(HexaPDF::Error) { @form.canvas } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hexapdf-0.4.0 | test/hexapdf/type/test_form.rb |
hexapdf-0.3.0 | test/hexapdf/type/test_form.rb |
hexapdf-0.2.0 | test/hexapdf/type/test_form.rb |