pdf-reader-find_text/test/pdf/reader/find_text_test.rb

37 lines
1.0 KiB
Ruby

# frozen_string_literal: true
require "test_helper"
class PDF::Reader::FindTextTest < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::PDF::Reader::FindText::VERSION
end
def test_that_it_finds_single_text_in_pdf
reader = PDF::Reader.new File.open('test/test.pdf')
results = reader.pages.first.find_text('MICHELANGELO')
assert_equal 1, results.size
assert_equal 25, results.first.x
assert_equal 25, results.first.y
end
def test_that_it_finds_multiple_text_in_pdf
reader = PDF::Reader.new File.open('test/test.pdf')
results = reader.pages.first.find_text('Cowabunga')
assert_equal 3, results.size
assert_equal 247.64, results.first.x
assert_equal 420.945, results.first.y
end
def test_that_it_finds_complicated_text_in_pdf
reader = PDF::Reader.new File.open('test/test.pdf')
results = reader.pages.first.find_text('Cowabunga, le cri des ninjas !')
assert_equal 3, results.size
assert_equal 247.64, results.first.x
assert_equal 420.945, results.first.y
end
end