sentence_spec.rb revision 8855a26fb8a7c3743d2ae2cb817e21fb23b674c4
ec96c6e3605c2e9eb5c0113e4e1b07b3b5228c8chenning muellerrequire 'spec_helper'
ec96c6e3605c2e9eb5c0113e4e1b07b3b5228c8chenning mueller
ec96c6e3605c2e9eb5c0113e4e1b07b3b5228c8chenning muellerdescribe Sentence do
ec96c6e3605c2e9eb5c0113e4e1b07b3b5228c8chenning mueller
ec96c6e3605c2e9eb5c0113e4e1b07b3b5228c8chenning mueller context 'Migrations' do
ec96c6e3605c2e9eb5c0113e4e1b07b3b5228c8chenning mueller it 'should have the correct integer columns' do
ec96c6e3605c2e9eb5c0113e4e1b07b3b5228c8chenning mueller %w( ontology_id comments_count ).each do |column|
ec96c6e3605c2e9eb5c0113e4e1b07b3b5228c8chenning mueller have_db_column(column).of_type(:integer)
ec96c6e3605c2e9eb5c0113e4e1b07b3b5228c8chenning mueller end
ec96c6e3605c2e9eb5c0113e4e1b07b3b5228c8chenning mueller end
ec96c6e3605c2e9eb5c0113e4e1b07b3b5228c8chenning mueller
ec96c6e3605c2e9eb5c0113e4e1b07b3b5228c8chenning mueller it 'should have the correct string columns' do
ec96c6e3605c2e9eb5c0113e4e1b07b3b5228c8chenning mueller %w( range ).each do |column|
ec96c6e3605c2e9eb5c0113e4e1b07b3b5228c8chenning mueller have_db_column(column).of_type(:string)
ec96c6e3605c2e9eb5c0113e4e1b07b3b5228c8chenning mueller end
ec96c6e3605c2e9eb5c0113e4e1b07b3b5228c8chenning mueller end
ec96c6e3605c2e9eb5c0113e4e1b07b3b5228c8chenning mueller
it 'should have the correct text columns' do
%w( name text display_text ).each do |column|
have_db_column(column).of_type(:text)
end
end
it { have_db_index([:ontology_id, :id]).unique(true) }
it { have_db_index([:ontology_id, :name]).unique(true) }
end
context 'Associations' do
it { belong_to :ontology }
it { have_and_belong_to_many :entities }
end
context 'OntologyInstance' do
let(:ontology) { create :single_ontology }
context 'creating Sentences' do
let(:sentence_hash) do
{
'name' => '... (if exists)',
'range' => 'Examples/Reichel:40.9'
}
end
before do
ontology.sentences.update_or_create_from_hash sentence_hash
end
context 'correct attribute' do
let(:sentence) { ontology.sentences.first }
%i[name range].each do |attr|
it "should be #{attr}" do
expect(sentence.send(attr)).to eq(sentence_hash[attr.to_s])
end
end
end
end
context 'OWL2 sentences' do
let(:ontology) { create :single_ontology }
let(:user) { create :user }
let(:sentence) { ontology.sentences.first }
before do
parse_this(user, ontology, hets_out_file('generations'))
end
it 'should have display_text set' do
expect(sentence.display_text).to_not be_nil
end
it "should not contain entities' iris" do
sentence.entities.each do |entity|
expect(sentence.display_text).to_not include(entity.iri)
end
end
end
end
context 'extracted names' do
let(:sentence) { create :sentence, :of_meta_ontology }
let(:class_names) { sentence.hierarchical_class_names }
let(:name1) { class_names.first }
let(:name2) { class_names.last }
it "should match iris\' fragments" do
expect(name1).to eq('https://github.com/ontohub/OOR_Ontohub_API/blob/master/Domain_fields.owl#Accounting_and_taxation')
expect(name2).to eq('https://github.com/ontohub/OOR_Ontohub_API/blob/master/Domain_fields.owl#Business_and_administration')
end
end
end