spec/henkei_spec.rb in henkei-1.23.0 vs spec/henkei_spec.rb in henkei-1.23.1

- old
+ new

@@ -1,10 +1,13 @@ # frozen_string_literal: true require 'helper.rb' require 'henkei' +# Some of the tests have been known to fail in weird and wonderful ways when `rails` is included +require 'rails' if ENV['INCLUDE_RAILS'] == 'true' + describe Henkei do let(:data) { File.read 'spec/samples/sample.docx' } before do ENV['JAVA_HOME'] = nil @@ -150,11 +153,11 @@ it '#html returns an empty body' do expect(henkei.html).to include '<body/>' expect(henkei.html).to include '<meta name="tiff:ImageWidth" content="792"/>' end - it '#mimetype returns an empty result' do + it '#mimetype returns `image/png`' do expect(henkei.mimetype.content_type).to eq 'image/png' end end end @@ -179,9 +182,21 @@ expect(henkei.text).to include 'The quick brown fox jumped over the lazy cat.' end specify '#metadata reads metadata' do expect(henkei.metadata['Content-Type']).to eq %w[application/vnd.apple.pages application/vnd.apple.pages] + end + end + + context 'when source is a remote PDF' do + let(:henkei) { Henkei.new 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf' } + + specify '#text reads text' do + expect(henkei.text).to include 'Dummy PDF file' + end + + specify '#metadata reads metadata' do + expect(henkei.metadata['Content-Type']).to eq 'application/pdf' end end context 'working as server mode' do specify '#starts and kills server' do