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

37 lines
1.0 KiB
Ruby
Raw Permalink Normal View History

2022-02-23 16:55:46 +01:00
# frozen_string_literal: true
require "test_helper"
2022-02-23 17:12:31 +01:00
class PDF::Reader::FindTextTest < Minitest::Test
2022-02-23 16:55:46 +01:00
def test_that_it_has_a_version_number
2022-02-23 17:12:31 +01:00
refute_nil ::PDF::Reader::FindText::VERSION
2022-02-23 16:55:46 +01:00
end
2022-11-25 16:40:15 +01:00
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
2022-02-23 16:55:46 +01:00
end
end