rdf-spec 0.3.4 → 0.3.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.3.4.1
@@ -6,6 +6,24 @@ share_as :RDF_Format do
6
6
  before(:each) do
7
7
  raise raise '+@format_class+ must be defined in a before(:each) block' unless instance_variable_get('@format_class')
8
8
  end
9
+
10
+ describe ".for" do
11
+ RDF::Format.file_extensions.each do |ext, formats|
12
+ it "detects #{formats.first} using file_name foo.#{ext}" do
13
+ RDF::Format.for(:file_name => "foo.#{ext}").should == formats.first
14
+ end
15
+
16
+ it "detects #{formats.first} using file_extension #{ext}" do
17
+ RDF::Format.for(:file_extension => ext).should == formats.first
18
+ end
19
+ end
20
+
21
+ RDF::Format.content_types.each do |content_type, formats|
22
+ it "detects #{formats.first} using content_type #{content_type}" do
23
+ RDF::Format.for(:content_type => content_type).should == formats.first
24
+ end
25
+ end
26
+ end
9
27
 
10
28
  describe ".reader" do
11
29
  it "returns a reader" do
@@ -1,58 +1,47 @@
1
- require 'rspec' # @see http://rubygems.org/gems/rspec
1
+ require 'rspec/matchers' # @see http://rubygems.org/gems/rspec
2
2
 
3
3
  module RDF; module Spec
4
4
  ##
5
5
  # RDF matchers for RSpec.
6
6
  #
7
- # @see http://rspec.rubyforge.org/rspec/1.2.9/classes/Spec/Matchers.html
7
+ # @see http://rubydoc.info/gems/rspec-expectations/frames
8
8
  module Matchers
9
- ##
10
- # Defines a new RSpec matcher.
11
- #
12
- # @param [Symbol] name
13
- # @return [void]
14
- def self.define(name, &declarations)
15
- define_method name do |*expected|
16
- ::RSpec::Matchers::Matcher.new(name, *expected, &declarations)
17
- end
18
- end
19
-
20
- define :be_countable do
9
+ RSpec::Matchers.define :be_countable do
21
10
  match do |countable|
22
11
  countable.should be_a_kind_of(RDF::Countable)
23
12
  true
24
13
  end
25
14
  end
26
15
 
27
- define :be_enumerable do
16
+ RSpec::Matchers.define :be_enumerable do
28
17
  match do |enumerable|
29
18
  enumerable.should be_a_kind_of(RDF::Enumerable)
30
19
  true
31
20
  end
32
21
  end
33
22
 
34
- define :be_an_enumerator do
23
+ RSpec::Matchers.define :be_an_enumerator do
35
24
  match do |enumerator|
36
25
  enumerator.should be_a_kind_of(RDF::Enumerator)
37
26
  true
38
27
  end
39
28
  end
40
29
 
41
- define :be_queryable do
30
+ RSpec::Matchers.define :be_queryable do
42
31
  match do |enumerable|
43
32
  enumerable.should be_a_kind_of(RDF::Queryable)
44
33
  true
45
34
  end
46
35
  end
47
36
 
48
- define :be_mutable do
37
+ RSpec::Matchers.define :be_mutable do
49
38
  match do |enumerable|
50
39
  enumerable.should be_a_kind_of(RDF::Mutable)
51
40
  true
52
41
  end
53
42
  end
54
43
 
55
- define :be_a_statement do
44
+ RSpec::Matchers.define :be_a_statement do
56
45
  match do |statement|
57
46
  statement.should be_instance_of(RDF::Statement)
58
47
  statement.subject.should be_a_kind_of(RDF::Resource)
@@ -62,7 +51,7 @@ module RDF; module Spec
62
51
  end
63
52
  end
64
53
 
65
- define :be_a_triple do
54
+ RSpec::Matchers.define :be_a_triple do
66
55
  match do |triple|
67
56
  triple.should be_instance_of(Array)
68
57
  triple.size.should == 3
@@ -73,7 +62,7 @@ module RDF; module Spec
73
62
  end
74
63
  end
75
64
 
76
- define :be_a_quad do
65
+ RSpec::Matchers.define :be_a_quad do
77
66
  match do |quad|
78
67
  quad.should be_instance_of(Array)
79
68
  quad.size.should == 4
@@ -85,42 +74,42 @@ module RDF; module Spec
85
74
  end
86
75
  end
87
76
 
88
- define :be_a_resource do
77
+ RSpec::Matchers.define :be_a_resource do
89
78
  match do |value|
90
79
  value.should be_a_kind_of(RDF::Resource)
91
80
  true
92
81
  end
93
82
  end
94
83
 
95
- define :be_a_node do
84
+ RSpec::Matchers.define :be_a_node do
96
85
  match do |value|
97
86
  value.should be_a_kind_of(RDF::Node)
98
87
  true
99
88
  end
100
89
  end
101
90
 
102
- define :be_a_uri do
91
+ RSpec::Matchers.define :be_a_uri do
103
92
  match do |value|
104
93
  value.should be_a_kind_of(RDF::URI)
105
94
  true
106
95
  end
107
96
  end
108
97
 
109
- define :be_a_value do
98
+ RSpec::Matchers.define :be_a_value do
110
99
  match do |value|
111
100
  value.should be_a_kind_of(RDF::Value) unless value.is_a?(String) # FIXME
112
101
  true
113
102
  end
114
103
  end
115
104
 
116
- define :be_a_list do
105
+ RSpec::Matchers.define :be_a_list do
117
106
  match do |value|
118
107
  value.should be_an(RDF::List)
119
108
  true
120
109
  end
121
110
  end
122
111
 
123
- define :be_a_vocabulary do |base_uri|
112
+ RSpec::Matchers.define :be_a_vocabulary do |base_uri|
124
113
  match do |vocabulary|
125
114
  vocabulary.should be_a_kind_of(Module)
126
115
  vocabulary.should respond_to(:to_uri)
@@ -130,7 +119,7 @@ module RDF; module Spec
130
119
  end
131
120
  end
132
121
 
133
- define :have_properties do |base_uri, properties|
122
+ RSpec::Matchers.define :have_properties do |base_uri, properties|
134
123
  match do |vocabulary|
135
124
  properties.map { |p| p.to_sym }.each do |property|
136
125
  vocabulary[property].should be_a_uri
@@ -145,7 +134,7 @@ module RDF; module Spec
145
134
  end
146
135
  end
147
136
 
148
- define :have_subclasses do |base_uri, klasses|
137
+ RSpec::Matchers.define :have_subclasses do |base_uri, klasses|
149
138
  match do |vocabulary|
150
139
  klasses.map { |k| k.to_sym }.each do |klass|
151
140
  # TODO
@@ -154,21 +143,21 @@ module RDF; module Spec
154
143
  end
155
144
  end
156
145
 
157
- define :be_a_repository do
146
+ RSpec::Matchers.define :be_a_repository do
158
147
  match do |repository|
159
148
  repository.should be_a_kind_of(RDF::Repository)
160
149
  true
161
150
  end
162
151
  end
163
152
 
164
- define :be_a_repository_of_size do |size|
153
+ RSpec::Matchers.define :be_a_repository_of_size do |size|
165
154
  match do |repository|
166
155
  repository.should be_a_repository
167
156
  repository.size == size
168
157
  end
169
158
  end
170
159
 
171
- define :have_predicate do |predicate, count|
160
+ RSpec::Matchers.define :have_predicate do |predicate, count|
172
161
  match do |queryable|
173
162
  if count.nil?
174
163
  queryable.has_predicate?(predicate)
@@ -110,7 +110,7 @@ share_as :RDF_Queryable do
110
110
  end
111
111
  end
112
112
 
113
- context "with specific patterns from SPARQL", :pending => "SPARQL compatibility" do
113
+ context "with specific patterns from SPARQL" do
114
114
  context "triple pattern combinations" do
115
115
  it "?s p o" do
116
116
  @queryable.query(:predicate => RDF::URI("http://example.org/p"), :object => RDF::Literal.new(1)).to_a.should ==
@@ -189,7 +189,7 @@ share_as :RDF_Queryable do
189
189
  end
190
190
  end
191
191
 
192
- context "with specific patterns", :pending => "SPARQL compatibility" do
192
+ context "with specific patterns" do
193
193
  # Note that "01" should not match 1, per data-r2/expr-equal/sameTerm
194
194
  {
195
195
  [RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1])],
@@ -216,7 +216,15 @@ share_as :RDF_Queryable do
216
216
  solutions.size.should == @statements.size
217
217
  end
218
218
 
219
- it "returns statements from named contexts with variable context", :pending => "SPARQL compatibility" do
219
+ it "returns statements from unnamed contexts with false context" do
220
+ pattern = RDF::Query::Pattern.new(nil, nil, nil, :context => false)
221
+ solutions = []
222
+ @queryable.send(:query_pattern, pattern) {|s| solutions << s}
223
+ context_statements = @queryable.statements.reject {|st| st.has_context?}.length
224
+ solutions.size.should == context_statements
225
+ end
226
+
227
+ it "returns statements from named contexts with variable context" do
220
228
  pattern = RDF::Query::Pattern.new(nil, nil, nil, :context => :c)
221
229
  solutions = []
222
230
  @queryable.send(:query_pattern, pattern) {|s| solutions << s}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-09-09 00:00:00.000000000Z
14
+ date: 2012-01-09 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
18
- requirement: &2165526260 !ruby/object:Gem::Requirement
18
+ requirement: &2154787400 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: 2.6.0
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *2165526260
26
+ version_requirements: *2154787400
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: yard
29
- requirement: &2165525680 !ruby/object:Gem::Requirement
29
+ requirement: &2154786940 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: 0.7.2
35
35
  type: :development
36
36
  prerelease: false
37
- version_requirements: *2165525680
37
+ version_requirements: *2154786940
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rdf
40
- requirement: &2165525120 !ruby/object:Gem::Requirement
40
+ requirement: &2154813600 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
@@ -45,7 +45,7 @@ dependencies:
45
45
  version: 0.3.4
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *2165525120
48
+ version_requirements: *2154813600
49
49
  description: RDF.rb plugin that provides RSpec matchers and shared examples for RDF
50
50
  objects.
51
51
  email: public-rdf-ruby@w3.org
@@ -118,8 +118,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  version: '0'
119
119
  requirements: []
120
120
  rubyforge_project: rdf
121
- rubygems_version: 1.8.6
121
+ rubygems_version: 1.8.10
122
122
  signing_key:
123
123
  specification_version: 3
124
124
  summary: RSpec extensions for RDF.rb.
125
125
  test_files: []
126
+ has_rdoc: false