-
Notifications
You must be signed in to change notification settings - Fork 11
/
spec_helper.rb
66 lines (60 loc) · 1.61 KB
/
spec_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require "bundler/setup"
require 'rubygems'
require 'rspec'
require 'yaml'
require 'rdf/isomorphic'
require 'rdf/spec'
require 'rdf/spec/matchers'
require 'rdf/turtle'
require 'rdf/vocab'
require_relative 'matchers'
begin
require 'nokogiri'
rescue LoadError
end
begin
require 'simplecov'
require 'simplecov-lcov'
SimpleCov::Formatter::LcovFormatter.config do |config|
#Coveralls is coverage by default/lcov. Send info results
config.report_with_single_file = true
config.single_report_path = 'coverage/lcov.info'
end
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::LcovFormatter
])
SimpleCov.start do
add_filter "/spec/"
add_filter "/lib/rdf/rdfa/reader/rexml.rb"
add_filter "/lib/rdf/rdfa/context.rb"
end
rescue LoadError
end
require 'rdf/rdfa'
::RSpec.configure do |c|
c.filter_run focus: true
c.run_all_when_everything_filtered = true
c.exclusion_filter = {
ruby: lambda { |version| !(RUBY_VERSION.to_s =~ /^#{version}/) },
}
c.include(RDF::Spec::Matchers)
end
TMP_DIR = File.join(File.expand_path(File.dirname(__FILE__)), "tmp")
# Heuristically detect the input stream
def detect_format(stream)
# Got to look into the file to see
if stream.is_a?(IO) || stream.is_a?(StringIO)
stream.rewind
string = stream.read(1000)
stream.rewind
else
string = stream.to_s
end
case string
when /<html/i then RDF::RDFa::Reader
when /@prefix/i then RDF::Turtle::Reader
else RDF::NTriples::Reader
end
end