Skip to content

Commit 153c658

Browse files
committed
Release 1.1.13
* Update to RSpec 3.0 syntax * Test class for HttpAdapter (@cbeer) * Shared examples for RDF::Literal (@no-reply) * Tighten up Repository implementation specs * Deprecate SharedContext examples using new RSpec shared_examples. Old version supported, but issues a deprecation warning. (@no-reply)
2 parents 14a46bf + 9deed13 commit 153c658

20 files changed

+1718
-1004
lines changed

CREDITS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
* John Fieber <[email protected]>
2+
* Tom Johnson <[email protected]>

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ follows:
5959
## Contributors
6060

6161
* [John Fieber](http://github.com/jfieber) - <http://github.com/jfieber>
62+
* [Tom Johnson](https://github.com/no-reply) - <https://github.com/no-reply>
6263

6364
## Contributing
6465

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.5
1+
1.1.13

lib/rdf/spec/countable.rb

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
require 'rdf/spec'
22

3-
module RDF_Countable
4-
extend RSpec::SharedContext
3+
RSpec.shared_examples 'an RDF::Countable' do
54
include RDF::Spec::Matchers
65

7-
before :each do
8-
raise '+@countable+ must be defined in a before(:each) block' unless instance_variable_get('@countable')
6+
before do
7+
raise 'countable must be set with `let(:countable)' unless
8+
defined? countable
99

1010
@statements = RDF::Spec.quads
1111

12-
if @countable.empty?
13-
if (@countable.writable? rescue false)
14-
@countable.insert_statements(@statements)
15-
elsif @countable.respond_to?(:<<)
16-
@statements.each { |statement| @countable << statement }
12+
if countable.empty?
13+
if (countable.writable? rescue false)
14+
countable.send(:insert_statements, @statements)
15+
elsif countable.respond_to?(:<<)
16+
@statements.each { |statement| countable << statement }
1717
else
18-
raise "+@countable+ must respond to #<< or be pre-populated with the statements in #{RDF::Spec::TRIPLES_FILE} in a before(:each) block"
18+
raise "+countable+ must respond to #<< or be pre-populated with the" \
19+
"statements in #{RDF::Spec::TRIPLES_FILE} in a before block"
1920
end
2021
end
2122
end
2223

2324
describe RDF::Countable do
24-
subject {@countable}
25+
subject {countable}
2526

2627
it {should respond_to(:empty?)}
2728
it {should_not be_empty}
@@ -44,3 +45,25 @@ module RDF_Countable
4445
end
4546
end
4647
end
48+
49+
##
50+
# @deprecated use `it_behaves_like "an RDF::Countable"` instead
51+
module RDF_Countable
52+
extend RSpec::SharedContext
53+
include RDF::Spec::Matchers
54+
55+
def self.included(mod)
56+
warn "[DEPRECATION] `RDF_Countable` is deprecated. "\
57+
"Please use `it_behaves_like 'an RDF::Countable'`"
58+
end
59+
60+
describe 'examples for' do
61+
include_examples 'an RDF::Countable' do
62+
let(:countable) { @countable }
63+
64+
before do
65+
raise '@countable must be defined' unless defined?(countable)
66+
end
67+
end
68+
end
69+
end

lib/rdf/spec/durable.rb

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,53 @@
1414
# File.delete('test.db') if File.exists?('test.db')
1515
# end
1616
#
17-
# include RDF_Repository
17+
# it_behaves_like 'an RDF::Repository'
1818
# end
1919
#end
20-
module RDF_Durable
21-
extend RSpec::SharedContext
20+
RSpec.shared_examples 'an RDF::Durable' do
2221
include RDF::Spec::Matchers
2322

2423
before :each do
25-
raise '+@load_durable+ must be defined in a before(:each) block' unless instance_variable_get('@load_durable')
24+
raise '+@load_durable+ must be defined in a before(:each) block' unless
25+
instance_variable_get('@load_durable')
2626
end
2727

28-
describe RDF::Durable do
29-
subject {@load_durable.call}
30-
it {should respond_to(:durable?)}
31-
it "should support #durable?" do
32-
expect([true,false]).to be_member(subject.durable?)
33-
end
28+
subject {@load_durable.call}
3429

35-
it {should respond_to(:nondurable?)}
36-
it "should support #nondurable?" do
37-
expect([true,false]).to be_member(@load_durable.call.nondurable?)
38-
end
39-
its(:nondurable?) {should_not == subject.durable?}
30+
it { should respond_to(:durable?) }
31+
32+
it "should support #durable?" do
33+
expect([true,false]).to be_member(subject.durable?)
34+
end
35+
36+
it {should respond_to(:nondurable?)}
37+
38+
it "should support #nondurable?" do
39+
expect([true,false]).to be_member(@load_durable.call.nondurable?)
40+
end
41+
42+
its(:nondurable?) {should_not == subject.durable?}
4043

41-
it "should save contents between instantiations" do
42-
if subject.durable?
43-
subject.load(RDF::Spec::TRIPLES_FILE)
44-
expect(subject.count).to eq File.readlines(RDF::Spec::TRIPLES_FILE).size
45-
end
44+
it "should save contents between instantiations" do
45+
if subject.durable?
46+
subject.load(RDF::Spec::TRIPLES_FILE)
47+
expect(subject.count).to eq File.readlines(RDF::Spec::TRIPLES_FILE).size
4648
end
4749
end
4850
end
51+
52+
##
53+
# @deprecated use `it_behaves_like "an RDF::Durable"` instead
54+
module RDF_Durable
55+
extend RSpec::SharedContext
56+
include RDF::Spec::Matchers
57+
58+
def self.included(mod)
59+
warn "[DEPRECATION] `RDF_Durable` is deprecated. "\
60+
"Please use `it_behaves_like 'an RDF::Durable'`"
61+
end
62+
63+
describe 'examples for' do
64+
include_examples 'an RDF::Durable'
65+
end
66+
end

0 commit comments

Comments
 (0)