Module: RDF::Spec

Defined in:
lib/rdf/spec.rb,
lib/rdf/spec/version.rb,
lib/rdf/spec/matchers.rb

Overview

RDF::Spec provides RSpec extensions for RDF.rb.

Examples:

Requiring the RDF::Spec module

require 'rdf/spec'

Including the matchers in spec/spec_helper.rb

require 'rdf/spec'

RSpec.configure do |config|
  config.include(RDF::Spec::Matchers)
end

Using the shared examples for RDF::Enumerable

require 'rdf/spec/enumerable'

describe RDF::Enumerable do
  before :each do
    @statements = RDF::NTriples::Reader.new(File.open("etc/doap.nt")).to_a
    @enumerable = @statements.dup.extend(RDF::Enumerable)
  end

  include RDF_Enumerable
end

Using the shared examples for RDF::Repository

require 'rdf/spec/repository'

describe RDF::Repository do
  before :each do
    @repository = RDF::Repository.new
  end

  include RDF_Repository
end

See Also:

Author:

Defined Under Namespace

Modules: Matchers, VERSION

Constant Summary collapse

TRIPLES_FILE =
File.expand_path("../../../etc/triples.nt", __FILE__)
QUADS_FILE =
File.expand_path("../../../etc/quads.nq", __FILE__)

Class Method Summary collapse

Class Method Details

.loggerObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/rdf/spec.rb', line 77

def self.logger
  logger = Logger.new(StringIO.new)
  logger.instance_eval do
    def clear
      @logdev.instance_variable_set(:@dev, StringIO.new)
    end
    def to_s
      dev = @logdev.instance_variable_get(:@dev)
      dev.rewind
      dev.read
    end
  end
  logger.level = Logger::DEBUG
  logger.formatter = lambda {|severity, datetime, progname, msg| "%5s %s\n" % [severity, msg]}
  logger
end

.quadsArray<RDF::Statement>

Return quads for tests

Returns:

  • (Array<RDF::Statement>)


61
62
63
64
# File 'lib/rdf/spec.rb', line 61

def self.quads
  require 'rdf/nquads'
  (@quads ||=  RDF::NQuads::Reader.new(File.open(QUADS_FILE)).to_a).dup
end

.triplesArray<RDF::Statement>

Return triples for tests

Returns:

  • (Array<RDF::Statement>)


70
71
72
73
# File 'lib/rdf/spec.rb', line 70

def self.triples
  require 'rdf/ntriples'
  (@triples ||=  RDF::NTriples::Reader.new(File.open(TRIPLES_FILE)).to_a).dup
end