sentence_test.rb revision 481313bedd6b4845bd732f90585eaa0dfa620a03
5N/Arequire 'test_helper'
5N/A
5N/Aclass SentenceTest < ActiveSupport::TestCase
5N/A
5N/A context 'Migrations' do
5N/A %w( ontology_id comments_count ).each do |column|
5N/A should have_db_column(column).of_type(:integer)
8N/A end
8N/A
8N/A %w( name range ).each do |column|
8N/A should have_db_column(column).of_type(:string)
105N/A end
105N/A
105N/A %w( text display_text ).each do |column|
105N/A should have_db_column(column).of_type(:text)
105N/A end
105N/A
105N/A should have_db_index([:ontology_id, :id]).unique(true)
105N/A should have_db_index([:ontology_id, :name]).unique(true)
105N/A end
105N/A
105N/A context 'Associations' do
105N/A should belong_to :ontology
105N/A should have_and_belong_to_many :entities
105N/A end
105N/A
105N/A context 'OntologyInstance' do
105N/A setup do
105N/A @ontology = FactoryGirl.create :single_ontology
105N/A end
105N/A
context 'creating Sentences' do
setup do
@sentence_hash = {
'name' => '... (if exists)',
'range' => 'Examples/Reichel:40.9'
}
@ontology.sentences.update_or_create_from_hash @sentence_hash
end
context 'correct attribute' do
setup do
@sentence = @ontology.sentences.first
end
%w[name range].each do |attr|
should "be #{attr}" do
assert_equal @sentence_hash[attr], eval("@sentence.#{attr}")
end
end
end
end
context 'OWL2 sentences' do
setup do
@ontology = FactoryGirl.create :single_ontology
@ontology.import_xml_from_file Rails.root + 'test/fixtures/ontologies/xml/generations.xml'
@sentence = @ontology.sentences.first
end
should 'have display_text set' do
assert_not_nil @sentence.display_text
end
should "not contain entities' iris" do
@sentence.entities.each do |x|
assert !(@sentence.text.include? x.iri)
end
end
end
end
end