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


75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/rdf/spec.rb', line 75

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

.quadsArray<RDF::Statement>

Return quads for tests

Returns:

  • (Array<RDF::Statement>)

59
60
61
62
# File 'lib/rdf/spec.rb', line 59

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>)

68
69
70
71
# File 'lib/rdf/spec.rb', line 68

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