require 'simple_bioc'
require 'test_xml/spec'
describe "Simple function" do
it "should have a DTD declaration" do
collection = SimpleBioC.from_xml("./xml/everything.xml")
output = SimpleBioC.to_xml(collection)
expect(output).to include('')
end
it "should no space when save_with = 0" do
collection = SimpleBioC.from_xml("./xml/everything.xml")
output = SimpleBioC.to_xml(collection, {save_with: 0})
expect(output).to include('Made up file to test that everything is allowed and processed. Has text in the passage.20130426everything.keycollection-infon-value1document-infon-valuepassage-infon-value0text of passageannotation-infon-valueannotation textpassage-relation-infon-valuedocument-relation-infon-value')
end
it "should process only one document by options" do
collection = SimpleBioC.from_xml("./xml/lemma.xml", {documents:[21785578, 21488974]})
output = SimpleBioC.to_xml(collection, {save_with: 0})
expect(output.scan("").size).to eq(2)
expect(output).to include("21785578")
expect(output).to include("21488974")
expect(output).not_to include("21660417")
expect(output).not_to include("21951408")
end
it "should have location node followed by text node" do
collection = SimpleBioC.from_xml("./xml/everything.xml")
output = SimpleBioC.to_xml(collection, {save_with: 0})
expect(output).to include('annotation text')
end
it "should read bioc from file" do
f = File.open("./xml/everything.xml")
collection = SimpleBioC.from_xml_file(f)
f.close
output = SimpleBioC.to_xml(collection)
expect(output).to include('')
end
it "should read bioc from string" do
f = File.open("./xml/everything.xml")
contents = f.read
collection = SimpleBioC.from_xml_file(contents)
f.close
output = SimpleBioC.to_xml(collection)
expect(output).to include('')
end
end