Sha256: 23dcc07e05db3fa127ea0c6c2dd131ec69d408ed883da344e179629b1f84161c

Contents?: true

Size: 1.97 KB

Versions: 2

Compression:

Stored size: 1.97 KB

Contents

require File.expand_path("../spec_helper", __FILE__)
require 'rdf/reasoner'

describe RDF::Vocab do
  describe ".each" do
    it "inumerates pre-defined vocabularies" do
      expect {|b| RDF::Vocabulary.each(&b)}.to yield_control.at_least(RDF::Vocab::VOCABS.keys.length).times
    end
  end

  context "pre-defined vocabularies" do
    RDF::Vocab::VOCABS.each do |id, params|
      class_name = params.fetch(:class_name, id.to_s.upcase).to_sym
      context id do
        it "defines RDF::Vocab::#{class_name}" do
          expect { RDF::Vocab.const_get(class_name) }.not_to raise_error
        end

        it "#{class_name} is included in RDF::Vocabulary.each" do
          expect(RDF::Vocabulary.each.to_a).to include(RDF::Vocab.const_get(class_name))
        end

        it "represents #{params[:uri]}" do
          expect(RDF::Vocab.const_get(class_name).to_s).to eql params[:uri]
        end
      end
    end
  end

  context "entailments" do
    before(:all) {
      RDF::Reasoner.apply(:rdfs, :owl)
    }
    RDF::Vocabulary.each do |vocab|
      vocab.each do |term|
        if term.type.to_s =~ /Class/
          context term.pname do
            it "subClassOf" do
              expect {term.subClassOf.map(&:pname)}.not_to raise_error
            end
            it "equivalentClass" do
              expect {term.equivalentClass.map(&:pname)}.not_to raise_error
            end
          end
        elsif term.type.to_s =~ /Property/
          context term.pname do
            it "subPropertyOf" do
              expect {term.subPropertyOf.map(&:pname)}.not_to raise_error
            end
            it "domain" do
              expect {term.domain.map(&:pname)}.not_to raise_error
            end
            it "range" do
              expect {term.range.map(&:pname)}.not_to raise_error
            end
            it "equivalentProperty" do
              expect {term.equivalentProperty.map(&:pname)}.not_to raise_error
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rdf-vocab-0.8.1 spec/vocab_spec.rb
rdf-vocab-0.8.0 spec/vocab_spec.rb