ontology_factory.rb revision cc33aa3b98466511c8b1a4fdbe30b43708695250
end
"#{Faker::Lorem.word}_#{n}"
end
name { FactoryGirl.generate :name }
logic { FactoryGirl.create :logic }
"#{ontology.parent.locid}//#{ontology.name}"
else
"/#{ontology.repository.path}/#{ontology.name}"
end
end
factory :done_ontology do
}, without_protection: true)
end
end
end
}, without_protection: true)
end
trait :with_version do
state: 'pending'
}, without_protection: true)
end
end
}, without_protection: true)
version.fast_parse = true
end
end
end
ontology.locid = "/#{ontology.repository.path}/#{ontology.name}"
end
# Should always be fully linked, so every child should
# have a linked (defined by the DO) pointing or sourcing
source: child_one,
end
end
trait :with_children do
ontology.children << FactoryGirl.build(:ontology,
parent: ontology,
repository: ontology.repository,
basepath: ontology.basepath,
file_extension: ontology.file_extension)
ontology.children << FactoryGirl.build(:ontology,
parent: ontology,
repository: ontology.repository,
basepath: ontology.basepath,
file_extension: ontology.file_extension)
end
end
trait :with_versioned_children do
after(:build) do |ontology|
version = ontology.versions.build({
commit_oid: '0'*40,
user: nil,
basepath: ontology.basepath,
file_extension: ontology.file_extension
}, without_protection: true)
version.fast_parse = true
version.do_not_parse!
logic = FactoryGirl.create(:logic)
child_one = FactoryGirl.build(:ontology, :with_version,
logic: logic,
repository: ontology.repository)
child_one.versions.first.parent = version
child_two = FactoryGirl.build(:ontology, :with_version,
logic: logic,
repository: ontology.repository)
child_two.versions.first.parent = version
FactoryGirl.create(:mapping,
source: child_one,
target: child_two,
ontology: ontology)
ontology.children.push(child_one, child_two)
end
end
factory :heterogeneous_ontology do |ontology|
ontology.after(:build) do |ontology|
logic_one = FactoryGirl.create(:logic)
logic_two = FactoryGirl.create(:logic)
ontology.children << FactoryGirl.build(:ontology,
logic: logic_one,
parent: ontology,
repository: ontology.repository)
ontology.children << FactoryGirl.build(:ontology,
logic: logic_two,
parent: ontology,
repository: ontology.repository)
end
end
factory :homogeneous_ontology do |ontology|
ontology.after(:build) do |ontology|
logic_one = FactoryGirl.create(:logic)
ontology.children << FactoryGirl.create(:ontology,
logic: logic_one,
repository: ontology.repository)
ontology.children << FactoryGirl.create(:ontology,
logic: logic_one,
repository: ontology.repository)
end
end
end
end
end