Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ tmp
/*.gem
/*.lock
/doc/
/coverage/
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: ruby
bundler_args: --without debug
script: "bundle exec rspec spec"
env:
- CI=true
rvm:
- 2.0
- 2.1
- 2.2
- jruby
- rbx-2
cache: bundler
sudo: false
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ gem "rdf", git: "git://github.com/ruby-rdf/rdf.git", branch: "develop"
group :development do
gem "wirble"
end

group :development, :test do
gem 'simplecov', require: false
gem 'coveralls', require: false
end
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ and shared examples for Ruby projects that use RDF.rb and RSpec.
* <http://github.com/ruby-rdf/rdf-spec>

[![Gem Version](https://badge.fury.io/rb/rdf-spec.png)](http://badge.fury.io/rb/rdf-spec)
[![Build Status](https://travis-ci.org/ruby-rdf/rdf-spec.png?branch=master)](http://travis-ci.org/ruby-rdf/rdf-spec)
[![Coverage Status](https://coveralls.io/repos/ruby-rdf/rdf-spec/badge.svg)](https://coveralls.io/r/ruby-rdf/rdf-spec)

## Documentation

Expand Down
11 changes: 11 additions & 0 deletions spec/countable_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'rdf/spec/countable'

describe RDF::Countable do
# @see lib/rdf/spec/countable.rb in rdf-spec
it_behaves_like 'an RDF::Countable' do
# The available reference implementations are `RDF::Repository` and
# `RDF::Graph`, but a plain Ruby array will do fine as well:
let(:countable) { RDF::Spec.quads.extend(described_class) }
end
end
12 changes: 12 additions & 0 deletions spec/durable_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'rdf/spec/durable'

describe RDF::Durable do
# The available reference implementations are `RDF::Repository` and
# `RDF::Graph`, but a plain Ruby array will do fine as well
# FIXME
before { @load_durable = lambda { RDF::Repository.new } }

# @see lib/rdf/spec/countable.rb in rdf-spec
it_behaves_like 'an RDF::Durable'
end
11 changes: 11 additions & 0 deletions spec/enumerable_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'rdf/spec/enumerable'

describe RDF::Enumerable do
# @see lib/rdf/spec/enumerable.rb in rdf-spec
it_behaves_like 'an RDF::Enumerable' do
# The available reference implementations are `RDF::Repository` and
# `RDF::Graph`, but a plain Ruby array will do fine as well:
let(:enumerable) { RDF::Spec.quads.extend(described_class) }
end
end
12 changes: 12 additions & 0 deletions spec/format_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'rdf/spec/format'
require 'rdf/ntriples'
require 'rdf/nquads'

describe RDF::Format do

# @see lib/rdf/spec/format.rb in rdf-spec
it_behaves_like 'an RDF::Format' do
let(:format_class) { described_class }
end
end
12 changes: 12 additions & 0 deletions spec/http_adapter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'webmock/rspec'
require 'rdf/ntriples'
require 'rdf/spec/http_adapter'

context "HTTP Adapters" do
context "using Net::HTTP" do
it_behaves_like 'an RDF::HttpAdapter' do
let(:http_adapter) { RDF::Util::File::NetHttpAdapter }
end
end
end
15 changes: 15 additions & 0 deletions spec/indexable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'rdf/spec/indexable'

describe RDF::Indexable do
# @see lib/rdf/spec/indexable.rb in rdf-spec
it_behaves_like 'an RDF::Indexable' do
# The available reference implementations are `RDF::Repository` and
# `RDF::Graph`, but a double will do fine as well:
let(:indexable) do
d = double("Indexable").extend(RDF::Indexable)
allow(d).to receive(:index!) {d}
d
end
end
end
7 changes: 7 additions & 0 deletions spec/inferable_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'rdf/spec/inferable'

describe RDF::Inferable do
# @see lib/rdf/spec/enumerable.rb in rdf-spec
it_behaves_like 'an RDF::Inferable'
end
75 changes: 75 additions & 0 deletions spec/literal_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'rdf/spec/literal'

describe RDF::Literal do
describe RDF::Literal::Boolean do
it_behaves_like 'RDF::Literal with datatype and grammar', "true", RDF::XSD.boolean
it_behaves_like 'RDF::Literal equality', "true", true
it_behaves_like 'RDF::Literal lexical values', "true"
it_behaves_like 'RDF::Literal canonicalization', RDF::XSD.boolean, [
%w(true true),
%w(false false),
%w(tRuE true),
%w(FaLsE false),
%w(1 true),
%w(0 false)
]
it_behaves_like 'RDF::Literal validation', RDF::XSD.boolean,
%w(true false tRuE FaLsE 1 0),
%w(foo 10)
end

describe RDF::Literal::Integer do
it_behaves_like 'RDF::Literal with datatype and grammar', "1", RDF::XSD.integer
it_behaves_like 'RDF::Literal equality', "1", 1
it_behaves_like 'RDF::Literal lexical values', "1"
it_behaves_like 'RDF::Literal canonicalization', RDF::XSD.integer, [
%w(01 1),
%w(1 1),
%w(-1 -1),
%w(+1 1)
]
it_behaves_like 'RDF::Literal validation', RDF::XSD.integer,
%w(1 10 100 01 +1 -1),
%w(foo 10.1 12xyz)
end

describe RDF::Literal::DateTime do
it_behaves_like 'RDF::Literal with datatype and grammar', "2010-01-01T00:00:00Z", RDF::XSD.dateTime
it_behaves_like 'RDF::Literal equality', "2010-01-01T00:00:00Z", DateTime.parse("2010-01-01T00:00:00Z")
it_behaves_like 'RDF::Literal lexical values', "2010-01-01T00:00:00Z"
it_behaves_like 'RDF::Literal canonicalization', RDF::XSD.dateTime, [
["2010-01-01T00:00:00Z", "2010-01-01T00:00:00Z", "12:00:00 AM UTC on Friday, 01 January 2010"],
["2010-01-01T00:00:00.0000Z", "2010-01-01T00:00:00Z", "12:00:00 AM UTC on Friday, 01 January 2010"],
["2010-01-01T00:00:00", "2010-01-01T00:00:00", "12:00:00 AM on Friday, 01 January 2010"],
["2010-01-01T00:00:00+00:00", "2010-01-01T00:00:00Z", "12:00:00 AM UTC on Friday, 01 January 2010"],
["2010-01-01T01:00:00+01:00", "2010-01-01T00:00:00Z", "01:00:00 AM +01:00 on Friday, 01 January 2010"],
["2009-12-31T23:00:00-01:00", "2010-01-01T00:00:00Z", "11:00:00 PM -01:00 on Thursday, 31 December 2009"],
["-2010-01-01T00:00:00Z", "-2010-01-01T00:00:00Z","12:00:00 AM UTC on Friday, 01 January -2010"],
#["2014-09-01T12:13:14.567", "2014-09-01T12:13:14", "12:13:14 PM on Monday, 01 September 2014"],
#["2014-09-01T12:13:14.567Z", "2014-09-01T12:13:14Z", "12:13:14 PM UTC on Monday, 01 September 2014"],
#["2014-09-01T12:13:14.567-08:00","2014-09-01T20:13:14Z","12:13:14 PM -08:00 on Monday, 01 September 2014"],
]
it_behaves_like 'RDF::Literal validation', RDF::XSD.dateTime,
%w(
2010-01-01T00:00:00Z
2010-01-01T00:00:00.0000Z
2010-01-01T00:00:00
2010-01-01T00:00:00+00:00
2010-01-01T01:00:00+01:00
2009-12-31T23:00:00-01:00
-2010-01-01T00:00:00Z
),
%w(
foo
+2010-01-01T00:00:00Z
2010-01-01T00:00:00FOO
02010-01-01T00:00:00
2010-01-01
2010-1-1T00:00:00
0000-01-01T00:00:00
2010-07
2010
)
end
end
11 changes: 11 additions & 0 deletions spec/mutable_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'rdf/spec/mutable'

describe RDF::Mutable do
# @see lib/rdf/spec/mutable.rb in rdf-spec
it_behaves_like 'an RDF::Mutable' do
# The available reference implementations are `RDF::Repository` and
# `RDF::Graph`
let(:mutable) { RDF::Repository.new }
end
end
13 changes: 13 additions & 0 deletions spec/queryable_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'rdf/spec/queryable'

describe RDF::Queryable do
# @see lib/rdf/spec/queryable.rb in rdf-spec
it_behaves_like 'an RDF::Queryable' do
# The available reference implementations are `RDF::Repository` and
# `RDF::Graph`, but a subclass of Ruby Array implementing
# `query_pattern` and `query_execute` should do as well
# FIXME
let(:queryable) { RDF::Repository.new }
end
end
11 changes: 11 additions & 0 deletions spec/readable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'rdf/spec/readable'

describe RDF::Readable do
# @see lib/rdf/spec/readable.rb in rdf-spec
it_behaves_like 'an RDF::Readable' do
# The available reference implementations are `RDF::Repository` and
# `RDF::Graph`, but a plain Ruby array will do fine as well:
let(:readable) { double("Readable").extend(RDF::Readable) }
end
end
17 changes: 17 additions & 0 deletions spec/reader_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- encoding: utf-8 -*-
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'rdf/ntriples'
require 'rdf/spec/reader'

describe RDF::NTriples::Reader do
let!(:doap) {File.expand_path("../../etc/doap.nt", __FILE__)}
let!(:doap_count) {File.open(doap).each_line.to_a.length}
subject { RDF::NTriples::Reader.new }

# @see lib/rdf/spec/reader.rb in rdf-spec
it_behaves_like 'an RDF::Reader' do
let(:reader) { RDF::NTriples::Reader.new }
let(:reader_input) { File.read(doap) }
let(:reader_count) { doap_count }
end
end
9 changes: 9 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
require "bundler/setup"
require 'rdf'
require 'simplecov'
require 'coveralls'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
]
SimpleCov.start do
add_filter "/spec/"
end
require 'rdf/spec'
require 'rdf/spec/matchers'

Expand Down
7 changes: 7 additions & 0 deletions spec/transaction_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'rdf/spec/transaction'

describe RDF::Transaction, skip: "pending fixes to immutability errors" do
# @see lib/rdf/spec/transaction.rb in rdf-spec
it_behaves_like "an RDF::Transaction", RDF::Transaction
end
13 changes: 13 additions & 0 deletions spec/writable_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'rdf/spec/writable'

describe RDF::Writable do
subject {RDF::Repository.new}

# @see lib/rdf/spec/writable.rb in rdf-spec
it_behaves_like 'an RDF::Writable' do
# The available reference implementations are `RDF::Repository` and
# `RDF::Graph`, but a plain Ruby array will do fine as well:
let(:writable) { RDF::Repository.new }
end
end
11 changes: 11 additions & 0 deletions spec/writer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- encoding: utf-8 -*-
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'rdf/ntriples'
require 'rdf/spec/writer'

describe RDF::NTriples::Writer do
# @see lib/rdf/spec/writer.rb in rdf-spec
it_behaves_like 'an RDF::Writer' do
let(:writer) { RDF::NTriples::Writer.new }
end
end