spec/rtesseract_spec.rb in rtesseract-2.0.0 vs spec/rtesseract_spec.rb in rtesseract-2.0.1
- old
+ new
@@ -79,10 +79,11 @@
expect(RTesseract.new(@image_tif, lang: 'portuguese').lang).to eql(' -l por ')
expect(RTesseract.new(@image_tif, lang: 'eng').to_s_without_spaces).to eql('43XF')
expect(RTesseract.new(@image_tif, lang: 'eng').lang).to eql(' -l eng ')
+ expect(RTesseract.new(@image_tif, lang: 'it').lang).to eql(' -l ita ')
# Invalid lang object
expect(RTesseract.new(@image_tif, lang: MakeStringError.new).lang).to eql('')
end
@@ -96,10 +97,11 @@
it ' be configurable' do
expect(RTesseract.new(@image_tif, chop_enable: 0, enable_assoc: 0, display_text: 0).config).to eql("chop_enable 0\nenable_assoc 0\ndisplay_text 0")
expect(RTesseract.new(@image_tif, chop_enable: 0).config).to eql('chop_enable 0')
expect(RTesseract.new(@image_tif, chop_enable: 0, enable_assoc: 0).config).to eql("chop_enable 0\nenable_assoc 0")
expect(RTesseract.new(@image_tif, chop_enable: 0).to_s_without_spaces).to eql('43XF')
+ expect(RTesseract.new(@image_tif, tessedit_char_whitelist: "ABCDEF12345").to_s_without_spaces).to eql('43F')
end
it ' crop image' do
expect(RTesseract.new(@image_tif, psm: 7).crop!(w: 36, h: 40, x: 140, y: 10).to_s_without_spaces).to eql('4')
expect(RTesseract.new(@image_tif, psm: 7).crop!(w: 36, h: 40, x: 180, y: 10).to_s_without_spaces).to eql('3')
@@ -119,18 +121,18 @@
expect { test.from_blob('') }.to raise_error(RTesseract::ConversionError)
end
it ' use a instance' do
expect(RTesseract.new(Magick::Image.read(@image_tif.to_s).first).to_s_without_spaces).to eql('43XF')
- expect(RMagickProcessor.a_name?('teste')).to eql(false)
- expect(RMagickProcessor.a_name?('rmagick')).to eql(true)
- expect(RMagickProcessor.a_name?('RMagickProcessor')).to eql(true)
- expect(MiniMagickProcessor.a_name?('teste')).to eql(false)
- expect(MiniMagickProcessor.a_name?('mini_magick')).to eql(true)
- expect(MiniMagickProcessor.a_name?('MiniMagickProcessor')).to eql(true)
- expect(NoneProcessor.a_name?('none')).to eql(true)
- expect(NoneProcessor.a_name?('NoneProcessor')).to eql(true)
+ expect(RTesseract::Processor::RMagickProcessor.a_name?('teste')).to eql(false)
+ expect(RTesseract::Processor::RMagickProcessor.a_name?('rmagick')).to eql(true)
+ expect(RTesseract::Processor::RMagickProcessor.a_name?('RMagickProcessor')).to eql(true)
+ expect(RTesseract::Processor::MiniMagickProcessor.a_name?('teste')).to eql(false)
+ expect(RTesseract::Processor::MiniMagickProcessor.a_name?('mini_magick')).to eql(true)
+ expect(RTesseract::Processor::MiniMagickProcessor.a_name?('MiniMagickProcessor')).to eql(true)
+ expect(RTesseract::Processor::NoneProcessor.a_name?('none')).to eql(true)
+ expect(RTesseract::Processor::NoneProcessor.a_name?('NoneProcessor')).to eql(true)
end
it ' change image in a block' do
test = RTesseract.read(@path.join('images', 'test.png').to_s) {}
expect(test.class).to eql(RTesseract)
@@ -170,14 +172,13 @@
# Invalid psm object
expect(RTesseract.new(@image_tif, psm: MakeStringError.new).psm).to eql('')
end
it 'remove a file' do
- rtesseract = RTesseract.new('.')
- rtesseract.remove_file(Tempfile.new('config'))
+ RTesseract::Utils.remove_files(Tempfile.new('config'))
- expect { rtesseract.remove_file(Pathname.new(Dir.tmpdir).join('test_not_exists')) }.to raise_error(RTesseract::TempFilesNotRemovedError)
+ expect { RTesseract::Utils.remove_files(Pathname.new(Dir.tmpdir).join('test_not_exists')) }.to raise_error(RTesseract::TempFilesNotRemovedError)
end
it ' support default config processors' do
# Rmagick
RTesseract.configure { |config| config.processor = 'rmagick' }
@@ -199,11 +200,10 @@
expect(RTesseract.new(@image_tif).lang).to eql(' -l por ')
RTesseract.configure { |config| config.psm = 7 }
expect(RTesseract.new(@image_tif).psm).to eql(' -psm 7 ')
-
RTesseract.configure { |config| config.tessdata_dir = '/tmp/test' }
expect(RTesseract.new(@image_tif).tessdata_dir).to eql(' --tessdata-dir /tmp/test ')
RTesseract.configure { |config| config.user_words = '/tmp/test' }
expect(RTesseract.new(@image_tif).user_words).to eql(' --user-words /tmp/test ')
@@ -218,7 +218,9 @@
expect(RTesseract.new(@image_tif, user_patterns: '/tmp/test').user_patterns).to eql(' --user-patterns /tmp/test ')
expect(RTesseract.new(@image_tif, tessdata_dir: MakeStringError.new).tessdata_dir).to eql('')
expect(RTesseract.new(@image_tif, user_words: MakeStringError.new).user_words).to eql('')
expect(RTesseract.new(@image_tif, user_patterns: MakeStringError.new).user_patterns).to eql('')
+
+ # expect(RTesseract.new(@path.join('images', 'test_words.png').to_s, psm: 3, user_words: @path.join('configs', 'eng.user-words.txt').to_s).to_s).to eql("If you are a friend,\nyou speak the password,\nand the doors will open.\n\n")
end
end