Skip to content

Commit 1e212f9

Browse files
committed
Merge branch 'origin/1.1'
2 parents 0a36f54 + 0bd5f48 commit 1e212f9

7 files changed

Lines changed: 102 additions & 50 deletions

File tree

.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
66
gem.date = File.mtime('VERSION').strftime('%Y-%m-%d')
77

88
gem.name = 'rdf-spec'
9-
gem.homepage = 'http://github.com/ruby-rdf/rdf-spec/'
9+
gem.homepage = 'http://ruby-rdf.github.com/rdf-spec/'
1010
gem.license = 'Public Domain' if gem.respond_to?(:license=)
1111
gem.summary = 'RSpec extensions for RDF.rb.'
1212
gem.description = 'RDF.rb plugin that provides RSpec matchers and shared examples for RDF objects.'
@@ -25,9 +25,9 @@ Gem::Specification.new do |gem|
2525
gem.test_files = %w()
2626
gem.has_rdoc = false
2727

28-
gem.required_ruby_version = '>= 1.8.7'
28+
gem.required_ruby_version = '>= 1.9.2'
2929
gem.requirements = []
30-
gem.add_development_dependency 'rdf', '~> 1.0'
30+
gem.add_development_dependency 'rdf', '~> 1.1'
3131
gem.add_runtime_dependency 'rspec', '>= 2.14'
3232
gem.add_development_dependency 'yard' , '>= 0.8'
3333
gem.post_install_message = nil

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ source "http://rubygems.org"
22

33
gemspec :name => ""
44

5-
gem "rdf", :git => "git://github.com/ruby-rdf/rdf.git"
5+
gem "rdf", :git => "git://github.com/ruby-rdf/rdf.git", :branch => "develop"
66

77
group :development do
88
gem "wirble"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ and shared examples for Ruby projects that use RDF.rb and RSpec.
55

66
* <http://github.com/ruby-rdf/rdf-spec>
77

8+
[![Gem Version](https://badge.fury.io/rb/rdf-spec.png)](http://badge.fury.io/rb/rdf-spec)
9+
810
## Documentation
911

1012
* {RDF::Spec}

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.9
1+
1.1.0

lib/rdf/spec/enumerable.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,15 +389,17 @@ module RDF_Enumerable
389389
describe "#each_graph" do
390390
subject {@enumerable.each_graph}
391391
it {should be_an_enumerator}
392-
specify {subject.each { |value| expect(value).to be_a_graph }}
392+
it "are all graphs" do
393+
subject.each { |value| expect(value).to be_a_graph } if @supports_context
394+
end
393395
end
394396

395397
describe "#enum_graph" do
396398
subject {@enumerable.enum_graph}
397399
it {should be_an_enumerator}
398400
it {should be_countable}
399401
it "enumerates the same as #each_graph" do
400-
subject.to_a.should =~ @enumerable.each_graph.to_a # expect with match problematic
402+
subject.to_a.should =~ @enumerable.each_graph.to_a if @supports_context # expect with match problematic
401403
end
402404
end
403405
end

lib/rdf/spec/matchers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module Matchers
2222

2323
RSpec::Matchers.define :be_an_enumerator do
2424
match do |enumerator|
25-
expect(enumerator).to be_a_kind_of(RDF::Enumerator)
25+
expect(enumerator).to be_a_kind_of(Enumerator)
2626
true
2727
end
2828
end

lib/rdf/spec/transaction.rb

Lines changed: 90 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,110 @@
11
require 'rdf/spec'
22

3-
module RDF_Transaction
4-
extend RSpec::SharedContext
3+
# Pass in an instance of RDF::Transaction as follows:
4+
#
5+
# it_behaves_like "RDF_Transaction", RDF::Transaction
6+
shared_examples "RDF_Transaction" do |klass|
57
include RDF::Spec::Matchers
68

7-
before :each do
8-
raise '+@transaction+ must be defined in a before(:each) block' unless instance_variable_get('@transaction')
9-
end
10-
119
describe RDF::Transaction do
12-
#TODO
10+
subject {klass.new(:context => RDF::URI("name"), :insert => RDF::Graph.new, :delete => RDF::Graph.new)}
11+
1312
describe "#initialize" do
14-
it "accepts a graph"
15-
it "accepts a context"
16-
it "accepts inserts"
17-
it "accepts deletes"
18-
end
19-
20-
describe "#graph" do
21-
it "is mutable"
13+
subject {klass}
14+
it "accepts a graph" do
15+
g = double("graph")
16+
this = subject.new(:graph => g)
17+
expect(this.graph).to eq g
18+
end
19+
20+
it "accepts a context" do
21+
c = double("context")
22+
this = subject.new(:graph => c)
23+
expect(this.graph).to eq c
24+
expect(this.context).to eq c
25+
26+
this = subject.new(:context => c)
27+
expect(this.graph).to eq c
28+
expect(this.context).to eq c
29+
end
30+
31+
it "accepts inserts" do
32+
g = double("inserts")
33+
this = subject.new(:insert => g)
34+
expect(this.inserts).to eq g
35+
end
36+
37+
it "accepts deletes" do
38+
g = double("deletes")
39+
this = subject.new(:delete => g)
40+
expect(this.deletes).to eq g
41+
end
2242
end
23-
24-
describe "#deletes" do
25-
it "is mutable"
43+
44+
its(:deletes) {should be_a(RDF::Enumerable)}
45+
its(:inserts) {should be_a(RDF::Enumerable)}
46+
it {should be_mutable}
47+
it {should_not be_readable}
48+
49+
it "does not respond to #load" do
50+
expect {subject.load("http://example/")}.to raise_error(NoMethodError)
2651
end
27-
28-
describe "#inserts" do
29-
it "is mutable"
52+
53+
it "does not respond to #update" do
54+
expect {subject.update(RDF::Statement.new)}.to raise_error(NoMethodError)
3055
end
31-
32-
describe "#readable?" do
33-
it "returns false" do
34-
expect(@transaction.readable?).to be_false
35-
end
56+
57+
it "does not respond to #clear" do
58+
expect {subject.clear}.to raise_error(NoMethodError)
3659
end
37-
60+
3861
describe "#execute" do
39-
it "deletes statements"
40-
it "inserts statements"
41-
it "calls before_execute"
42-
it "calls after_execute"
43-
it "returns self"
44-
it "does not delete statements on failures"
45-
it "does not insert statements on failures"
62+
let(:s) {RDF::Statement.new(RDF::URI("s"), RDF::URI("p"), RDF::URI("o"))}
63+
let(:r) {double("repository")}
64+
65+
it "deletes statements" do
66+
expect(r).to receive(:delete).with(s)
67+
expect(r).not_to receive(:insert)
68+
subject.delete(s)
69+
subject.execute(r)
70+
end
71+
72+
it "inserts statements" do
73+
expect(r).not_to receive(:delete)
74+
expect(r).to receive(:insert).with(s)
75+
subject.insert(s)
76+
subject.execute(r)
77+
end
78+
79+
it "calls before_execute" do
80+
expect(subject).to receive(:before_execute).with(r, {})
81+
subject.execute(r)
82+
end
83+
84+
it "calls after_execute" do
85+
expect(subject).to receive(:after_execute).with(r, {})
86+
subject.execute(r)
87+
end
88+
89+
it "returns self" do
90+
expect(subject.execute(r)).to eq subject
91+
end
4692
end
4793

4894
describe "#delete_statement" do
49-
it "adds statement to #deletes"
50-
it "does not remove statement from graph"
95+
let(:s) {RDF::Statement.new(RDF::URI("s"), RDF::URI("p"), RDF::URI("o"))}
96+
it "adds statement to #deletes" do
97+
subject.delete(s)
98+
expect(subject.deletes.to_a).to eq [s]
99+
end
51100
end
52101

53102
describe "#insert_statement" do
54-
it "adds statement to #inserts"
55-
it "does not add statement to graph"
103+
let(:s) {RDF::Statement.new(RDF::URI("s"), RDF::URI("p"), RDF::URI("o"))}
104+
it "adds statement to #inserts" do
105+
subject.insert(s)
106+
expect(subject.inserts.to_a).to eq [s]
107+
end
56108
end
57-
58-
it "does not respond to #load"
59-
it "does not respond to #update"
60-
it "does not respond to #clear"
61109
end
62110
end

0 commit comments

Comments
 (0)