distributed_spec.rb revision a68d1165fe4fb7cdd4f348a5313144fa86534868
2748N/Arequire 'spec_helper'
418N/A
418N/Adescribe 'Ontology::Distributed' do
418N/A let(:single) { FactoryGirl.create(:single_ontology) }
2748N/A let(:hetero_distributed) { FactoryGirl.create(:heterogeneous_ontology) }
418N/A let(:homogeneous_distributed) { FactoryGirl.create(:homogeneous_ontology) }
418N/A
418N/A context 'heterogeneity' do
418N/A it 'always be false if ontology is not distributed' do
418N/A expect(single.heterogeneous?).to be(false)
418N/A end
418N/A
418N/A context 'only be true if not all children of '\
418N/A 'distributed ontology are of same logic' do
418N/A it 'heterogeneous registers as heterogeneous' do
418N/A expect(hetero_distributed.heterogeneous?).to be(true)
418N/A end
418N/A it 'homogeneous registers as not heterogeneous' do
418N/A expect(homogeneous_distributed.heterogeneous?).to be(false)
418N/A end
418N/A end
418N/A
418N/A context 'only be true if not all children of '\
418N/A 'distributed ontology are of same logic' do
2748N/A it 'heterogeneous registers as heterogeneous' do
418N/A expect(hetero_distributed.heterogeneous?).to be(true)
418N/A end
418N/A it 'homogeneous registers as not heterogeneous' do
418N/A expect(homogeneous_distributed.heterogeneous?).to be(false)
418N/A end
418N/A end
418N/A
418N/A context 'collections: homogeneous are distributed' do
418N/A Ontology.homogeneous.map do |ontology|
418N/A it "#{ontology} is homogeneous" do
418N/A expect(ontology.homogeneous?).to be(true)
418N/A end
418N/A it "#{ontology} is distributed" do
418N/A expect(ontology.distributed?).to be(true)
418N/A end
418N/A end
418N/A
418N/A context 'can be filtered according to a specific logic' do
418N/A let(:ontology) { FactoryGirl.create(:heterogeneous_ontology) }
418N/A let(:logic) { ontology.children.first.logic }
418N/A let!(:ontologies) { Ontology.also_distributed_in(logic) }
418N/A
418N/A context 'retrieve only distributed ontologies '\
418N/A 'whose children belong to logic' do
418N/A it 'one_uses' do
418N/A ontologies.each do |ontology|
418N/A expect(ontology.children.any? { |child| child.logic == logic }).
418N/A to be(true)
418N/A end
418N/A end
418N/A
418N/A it "one doesn't use" do
2748N/A ontologies.each do |ontology|
418N/A expect(ontology.children.any? { |child| child.logic != logic }).
418N/A to be(true)
418N/A end
418N/A end
418N/A end
418N/A
418N/A it 'retrieve the right number of ontologies' do
418N/A expect(ontologies.size).to eq(1)
418N/A end
418N/A
418N/A it 'include the right distributed ontology(/ies)' do
418N/A expect(ontologies).to include(ontology)
418N/A end
418N/A end
418N/A end
418N/A end
418N/A
418N/A context 'homogeneity' do
418N/A it 'always be true if ontology is not distributed' do
418N/A expect(single.homogeneous?).to be(true)
418N/A end
418N/A
418N/A context 'only be true if all children of '\
418N/A 'distributed ontology are of same logic' do
418N/A it 'homogeneous registers as homogeneous' do
418N/A expect(homogeneous_distributed.homogeneous?).to be(true)
418N/A end
418N/A it 'heterogeneous registers as not homogeneous' do
418N/A expect(hetero_distributed.homogeneous?).to be(false)
418N/A end
418N/A end
2748N/A
2748N/A context 'collections' do
2748N/A before do
418N/A FactoryGirl.create_list(:heterogeneous_ontology, 10)
418N/A FactoryGirl.create_list(:homogeneous_ontology, 10)
418N/A end
418N/A
418N/A context 'return only distributed homogeneous ontologies' do
418N/A Ontology.homogeneous.map do |ontology|
418N/A it "#{ontology} is homogeneous" do
418N/A expect(ontology.homogeneous?).to be(true)
418N/A end
418N/A it "#{ontology} is distributed" do
418N/A expect(ontology.distributed?).to be(true)
418N/A end
418N/A end
418N/A end
418N/A
418N/A context 'can be filtered according to a specific logic' do
418N/A let(:ontology) { FactoryGirl.create(:homogeneous_ontology) }
418N/A let(:logic) { ontology.children.first.logic }
418N/A let(:ontologies) { Ontology.distributed_in(logic) }
418N/A
418N/A it 'retrieve only distributed ontologies '\
2748N/A 'which children belong to logic' do
418N/A ontologies.each do |ontology|
418N/A ontology.children.each do |child_ontology|
418N/A expect(child_ontology.logic).to eq(logic)
418N/A end
418N/A end
418N/A end
418N/A
418N/A it 'retrieve the right number of ontologies' do
418N/A expect(ontologies.size).to eq(1)
418N/A end
418N/A
418N/A it 'include the right distributed ontology(/ies)' do
418N/A expect(ontologies).to include(ontology)
418N/A end
418N/A end
418N/A end
418N/A end
418N/Aend
418N/A