require 'spec_helper'
describe RubyTikaApp do
before(:each) do
doc_path = "#{File.join(File.dirname(__FILE__))}/docs"
@test_file = "#{doc_path}/graph sampling simplex - 11.pdf"
@cnn_com_file = "#{doc_path}/cnn.com"
@news_ycombinator_com_file = "#{doc_path}/news.ycombinator.com"
end
describe 'Error' do
it 'has an error' do
expect {
rta = RubyTikaApp.new('No file')
rta.to_xml
}.to raise_error(RuntimeError)
end
end
describe '#to_xml' do
it 'header' do
rta = RubyTikaApp.new(@test_file)
expect(rta.to_xml[0..37]).to eq("")
end
it 'middle' do
rta = RubyTikaApp.new(@test_file)
xml = rta.to_xml
xml_size = xml.size / 2
expect(xml[xml_size..(xml_size + 100)]).to eq("plicated nodes make the node distribution converge\nto uniform distribution. We do not need to conside")
end
end
describe '#to_html' do
it 'header' do
rta = RubyTikaApp.new(@test_file)
expect(rta.to_html[0..42]).to eq("")
end
it 'middle' do
rta = RubyTikaApp.new(@test_file)
expect(rta.to_html[1000 ... 1100]).to eq("on/pdf\"/>\n\n