spec/henkei_spec.rb in henkei-1.17.3 vs spec/henkei_spec.rb in henkei-1.17.4

- old
+ new

@@ -10,31 +10,35 @@ describe '.read' do it 'reads text' do text = Henkei.read :text, data - expect( text ).to include 'The quick brown fox jumped over the lazy cat.' + expect(text).to include 'The quick brown fox jumped over the lazy cat.' end it 'reads metadata' do metadata = Henkei.read :metadata, data - expect( metadata['Content-Type'] ).to eql 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' + expect(metadata['Content-Type']).to( + eq 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' + ) end it 'reads metadata values with colons as strings' do data = File.read 'spec/samples/sample-metadata-values-with-colons.doc' metadata = Henkei.read :metadata, data - expect( metadata['dc:title'] ).to eql 'problem: test' + expect(metadata['dc:title']).to eq 'problem: test' end it 'reads mimetype' do mimetype = Henkei.read :mimetype, data - expect( mimetype.content_type ).to eql 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' - expect( mimetype.extensions ).to include 'docx' + expect(mimetype.content_type).to( + eq 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' + ) + expect(mimetype.extensions).to include 'docx' end end describe '.new' do it 'requires parameters' do @@ -42,113 +46,114 @@ end it 'accepts a root path' do henkei = Henkei.new 'spec/samples/sample.pages' - expect( henkei ).to be_path - expect( henkei ).not_to be_uri - expect( henkei ).not_to be_stream + expect(henkei).to be_path + expect(henkei).not_to be_uri + expect(henkei).not_to be_stream end it 'accepts a relative path' do henkei = Henkei.new 'spec/samples/sample.pages' - expect( henkei ).to be_path - expect( henkei ).not_to be_uri - expect( henkei ).not_to be_stream + expect(henkei).to be_path + expect(henkei).not_to be_uri + expect(henkei).not_to be_stream end it 'accepts a path with spaces' do henkei = Henkei.new 'spec/samples/sample filename with spaces.pages' - expect( henkei ).to be_path - expect( henkei ).not_to be_uri - expect( henkei ).not_to be_stream + expect(henkei).to be_path + expect(henkei).not_to be_uri + expect(henkei).not_to be_stream end it 'accepts a URI' do henkei = Henkei.new 'http://svn.apache.org/repos/asf/poi/trunk/test-data/document/sample.docx' - expect( henkei ).to be_uri - expect( henkei ).not_to be_path - expect( henkei ).not_to be_stream + expect(henkei).to be_uri + expect(henkei).not_to be_path + expect(henkei).not_to be_stream end it 'accepts a stream or object that can be read' do File.open 'spec/samples/sample.pages', 'r' do |file| henkei = Henkei.new file - expect( henkei ).to be_stream - expect( henkei ).not_to be_path - expect( henkei ).not_to be_uri + expect(henkei).to be_stream + expect(henkei).not_to be_path + expect(henkei).not_to be_uri end end it 'refuses a path to a missing file' do - expect { Henkei.new 'test/sample/missing.pages'}.to raise_error Errno::ENOENT + expect { Henkei.new 'test/sample/missing.pages' }.to raise_error Errno::ENOENT end it 'refuses other objects' do [nil, 1, 1.1].each do |object| expect { Henkei.new object }.to raise_error TypeError end end end - describe '.creation_date' do let(:henkei) { Henkei.new 'spec/samples/sample.pages' } it 'should return Time' do - expect( henkei.creation_date ).to be_a Time + expect(henkei.creation_date).to be_a Time end end describe '.java' do specify 'with no specified JAVA_HOME' do - expect( Henkei.send(:java_path) ).to eql 'java' + expect(Henkei.send(:java_path)).to eq 'java' end specify 'with a specified JAVA_HOME' do ENV['JAVA_HOME'] = '/path/to/java/home' - expect( Henkei.send(:java_path) ).to eql '/path/to/java/home/bin/java' + expect(Henkei.send(:java_path)).to eq '/path/to/java/home/bin/java' end end context 'initialized with a given path' do let(:henkei) { Henkei.new 'spec/samples/sample.pages' } specify '#text reads text' do - expect( henkei.text).to include 'The quick brown fox jumped over the lazy cat.' + 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 eql ['application/vnd.apple.pages', 'application/vnd.apple.pages'] + expect(henkei.metadata['Content-Type']).to eq %w[application/vnd.apple.pages application/vnd.apple.pages] end end context 'initialized with a given URI' do let(:henkei) { Henkei.new 'http://svn.apache.org/repos/asf/poi/trunk/test-data/document/sample.docx' } specify '#text reads text' do - expect( henkei.text ).to include 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit.' + expect(henkei.text).to include 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit.' end specify '#metadata reads metadata' do - expect( henkei.metadata['Content-Type'] ).to eql 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' + expect(henkei.metadata['Content-Type']).to( + eq 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' + ) end end context 'initialized with a given stream' do let(:henkei) { Henkei.new File.open('spec/samples/sample.pages', 'rb') } specify '#text reads text' do - expect( henkei.text ).to include 'The quick brown fox jumped over the lazy cat.' + 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 eql ['application/vnd.apple.pages', 'application/vnd.apple.pages'] + expect(henkei.metadata['Content-Type']).to eq %w[application/vnd.apple.pages application/vnd.apple.pages] end end context 'working as server mode' do specify '#starts and kills server' do @@ -169,12 +174,18 @@ end specify '#runs samples through server mode' do begin Henkei.server(:text) - expect(Henkei.new('spec/samples/sample.pages').text).to include 'The quick brown fox jumped over the lazy cat.' - expect(Henkei.new('spec/samples/sample filename with spaces.pages').text).to include 'The quick brown fox jumped over the lazy cat.' - expect(Henkei.new('spec/samples/sample.docx').text).to include 'The quick brown fox jumped over the lazy cat.' + expect(Henkei.new('spec/samples/sample.pages').text).to( + include 'The quick brown fox jumped over the lazy cat.' + ) + expect(Henkei.new('spec/samples/sample filename with spaces.pages').text).to( + include 'The quick brown fox jumped over the lazy cat.' + ) + expect(Henkei.new('spec/samples/sample.docx').text).to( + include 'The quick brown fox jumped over the lazy cat.' + ) ensure Henkei.kill_server! end end end