ladder 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,4 @@
1
1
  shared_context 'a Searchable File' do
2
-
3
2
  describe '#save' do
4
3
  before do
5
4
  subject.save
@@ -18,7 +17,7 @@ shared_context 'a Searchable File' do
18
17
  expect(results.first.fields.file.first).to include 'Moomin'
19
18
  end
20
19
  end
21
-
20
+
22
21
  describe '#save with update' do
23
22
  before do
24
23
  subject.save
@@ -46,5 +45,4 @@ shared_context 'a Searchable File' do
46
45
  expect(results).to be_empty
47
46
  end
48
47
  end
49
-
50
- end
48
+ end
@@ -1,7 +1,5 @@
1
1
  shared_examples 'a Searchable' do
2
-
3
2
  describe '#index_for_search' do
4
-
5
3
  context 'with default' do
6
4
  before do
7
5
  subject.save
@@ -41,8 +39,7 @@ shared_examples 'a Searchable' do
41
39
  expect(results.count).to eq 1
42
40
  expect(results.first._source.to_hash).to eq subject.as_jsonld
43
41
  end
44
- end
45
-
42
+ end
46
43
  end
47
44
 
48
45
  describe '#save with update' do
@@ -72,152 +69,147 @@ shared_examples 'a Searchable' do
72
69
  expect(results).to be_empty
73
70
  end
74
71
  end
75
-
76
72
  end
77
73
 
78
74
  shared_examples 'a Searchable with related' do
79
-
80
75
  describe '#index_for_search related' do
76
+ context 'with default' do
77
+ before do
78
+ subject.save
79
+ Elasticsearch::Model.client.indices.flush
80
+ end
81
+
82
+ it 'should contain an ID for the related object' do
83
+ results = subject.class.search('person_ids.$oid:' + person.id)
84
+ expect(results.count).to eq 1
85
+ expect(results.first._source.to_hash).to eq JSON.parse(subject.as_indexed_json.to_json)
86
+ end
87
+
88
+ it 'should include the related object in the index' do
89
+ results = person.class.search('foaf_name:tove')
90
+ expect(results.count).to eq 1
91
+ expect(results.first._source.to_hash).to eq JSON.parse(person.as_indexed_json.to_json)
92
+ end
93
+
94
+ it 'should contain an ID for the subject' do
95
+ results = person.class.search('thing_ids.$oid:' + subject.id)
96
+ expect(results.count).to eq 1
97
+ end
98
+ end
99
+
100
+ context 'with as qname' do
101
+ before do
102
+ person.class.index_for_search { as_qname }
103
+ subject.class.index_for_search { as_qname }
104
+ subject.save
105
+ Elasticsearch::Model.client.indices.flush
106
+ end
107
+
108
+ it 'should contain an ID for the related object' do
109
+ results = subject.class.search('dc.creator:' + person.id)
110
+ expect(results.count).to eq 1
111
+ expect(results.first._source.to_hash).to eq JSON.parse(subject.as_qname.to_json)
112
+ end
81
113
 
82
- context 'with default' do
83
- before do
84
- subject.save
85
- Elasticsearch::Model.client.indices.flush
86
- end
87
-
88
- it 'should contain an ID for the related object' do
89
- results = subject.class.search('person_ids.$oid:' + person.id)
90
- expect(results.count).to eq 1
91
- expect(results.first._source.to_hash).to eq JSON.parse(subject.as_indexed_json.to_json)
92
- end
93
-
94
- it 'should include the related object in the index' do
95
- results = person.class.search('foaf_name:tove')
96
- expect(results.count).to eq 1
97
- expect(results.first._source.to_hash).to eq JSON.parse(person.as_indexed_json.to_json)
98
- end
99
-
100
- it 'should contain an ID for the subject' do
101
- results = person.class.search('thing_ids.$oid:' + subject.id)
102
- expect(results.count).to eq 1
103
- end
104
- end
105
-
106
- context 'with as qname' do
107
- before do
108
- person.class.index_for_search { as_qname }
109
- subject.class.index_for_search { as_qname }
110
- subject.save
111
- Elasticsearch::Model.client.indices.flush
112
- end
113
-
114
- it 'should contain an ID for the related object' do
115
- results = subject.class.search('dc.creator:' + person.id)
116
- expect(results.count).to eq 1
117
- expect(results.first._source.to_hash).to eq JSON.parse(subject.as_qname.to_json)
118
- end
119
-
120
- it 'should include the related object in the index' do
121
- results = person.class.search('foaf.name.en:tove')
122
- expect(results.count).to eq 1
123
- expect(results.first._source.to_hash).to eq JSON.parse(person.as_qname.to_json)
124
- end
125
-
126
- it 'should contain an ID for the subject' do
127
- results = person.class.search('dc.relation:' + subject.id)
128
- expect(results.count).to eq 1
129
- end
130
- end
131
-
132
- context 'with as_qname related' do
133
- before do
134
- person.class.index_for_search { as_qname related: true }
135
- subject.class.index_for_search { as_qname related: true }
136
- subject.save
137
- Elasticsearch::Model.client.indices.flush
138
- end
139
-
140
- it 'should contain a embedded related object' do
141
- results = subject.class.search('dc.creator.foaf.name.en:tove')
142
- expect(results.count).to eq 1
143
- expect(results.first._source.to_hash).to eq JSON.parse(subject.as_qname(related: true).to_json)
144
- end
145
-
146
- it 'should contain an embedded subject in the related object' do
147
- results = person.class.search('dc.relation.dc.title.en:moomin*')
148
- expect(results.count).to eq 1
149
- expect(results.first._source.to_hash).to eq JSON.parse(person.as_qname(related: true).to_json)
150
- end
151
- end
152
-
153
- context 'with as_jsonld' do
154
- before do
155
- person.class.index_for_search { as_jsonld }
156
- subject.class.index_for_search { as_jsonld }
157
- subject.save
158
- Elasticsearch::Model.client.indices.flush
159
- end
160
-
161
- it 'should contain an ID for the related object' do
162
- results = subject.class.search('dc\:creator.@id:' + person.id)
163
- expect(results.count).to eq 1
164
- expect(results.first._source.to_hash).to eq subject.as_jsonld
165
- end
166
-
167
- it 'should include the related object in the index' do
168
- results = person.class.search('foaf\:name.@value:tove')
169
- expect(results.count).to eq 1
170
- expect(results.first._source.to_hash).to eq person.as_jsonld
171
- end
172
-
173
- it 'should contain an ID for the subject' do
174
- results = person.class.search('dc\:relation.@id:' + subject.id)
175
- expect(results.count).to eq 1
176
- end
177
- end
178
-
179
- context 'with as_jsonld related' do
180
- before do
181
- person.class.index_for_search { as_jsonld related: true }
182
- subject.class.index_for_search { as_jsonld related: true }
183
- subject.save
184
- Elasticsearch::Model.client.indices.flush
185
- end
186
-
187
- it 'should contain a embedded related object' do
188
- results = subject.class.search('@graph.foaf\:name.@value:tove')
189
- expect(results.count).to eq 1
190
- expect(results.first._source.to_hash).to eq JSON.parse(subject.as_jsonld(related: true).to_json)
191
- end
192
-
193
- it 'should contain an embedded subject in the related object' do
194
- results = person.class.search('@graph.dc\:title.@value:moomin*')
195
- expect(results.count).to eq 1
196
- expect(results.first._source.to_hash).to eq JSON.parse(person.as_jsonld(related: true).to_json)
197
- end
198
- end
199
-
200
- context 'with as_framed_jsonld' do
201
- before do
202
- person.class.index_for_search { as_framed_jsonld }
203
- subject.class.index_for_search { as_framed_jsonld }
204
- subject.save
205
- Elasticsearch::Model.client.indices.flush
206
- end
207
-
208
- it 'should contain a embedded related object' do
209
- results = subject.class.search('dc\:creator.foaf\:name.@value:tove')
210
- expect(results.count).to eq 1
211
- expect(results.first._source.to_hash).to eq JSON.parse(subject.as_framed_jsonld.to_json)
212
- end
213
-
214
- it 'should contain an embedded subject in the related object' do
215
- results = person.class.search('dc\:relation.dc\:title.@value:moomin*')
216
- expect(results.count).to eq 1
217
- expect(results.first._source.to_hash).to eq JSON.parse(person.as_framed_jsonld.to_json)
218
- end
114
+ it 'should include the related object in the index' do
115
+ results = person.class.search('foaf.name.en:tove')
116
+ expect(results.count).to eq 1
117
+ expect(results.first._source.to_hash).to eq JSON.parse(person.as_qname.to_json)
219
118
  end
220
119
 
120
+ it 'should contain an ID for the subject' do
121
+ results = person.class.search('dc.relation:' + subject.id)
122
+ expect(results.count).to eq 1
123
+ end
124
+ end
125
+
126
+ context 'with as_qname related' do
127
+ before do
128
+ person.class.index_for_search { as_qname related: true }
129
+ subject.class.index_for_search { as_qname related: true }
130
+ subject.save
131
+ Elasticsearch::Model.client.indices.flush
132
+ end
133
+
134
+ it 'should contain a embedded related object' do
135
+ results = subject.class.search('dc.creator.foaf.name.en:tove')
136
+ expect(results.count).to eq 1
137
+ expect(results.first._source.to_hash).to eq JSON.parse(subject.as_qname(related: true).to_json)
138
+ end
139
+
140
+ it 'should contain an embedded subject in the related object' do
141
+ results = person.class.search('dc.relation.dc.title.en:moomin*')
142
+ expect(results.count).to eq 1
143
+ expect(results.first._source.to_hash).to eq JSON.parse(person.as_qname(related: true).to_json)
144
+ end
145
+ end
146
+
147
+ context 'with as_jsonld' do
148
+ before do
149
+ person.class.index_for_search { as_jsonld }
150
+ subject.class.index_for_search { as_jsonld }
151
+ subject.save
152
+ Elasticsearch::Model.client.indices.flush
153
+ end
154
+
155
+ it 'should contain an ID for the related object' do
156
+ results = subject.class.search('dc\:creator.@id:' + person.id)
157
+ expect(results.count).to eq 1
158
+ expect(results.first._source.to_hash).to eq subject.as_jsonld
159
+ end
160
+
161
+ it 'should include the related object in the index' do
162
+ results = person.class.search('foaf\:name.@value:tove')
163
+ expect(results.count).to eq 1
164
+ expect(results.first._source.to_hash).to eq person.as_jsonld
165
+ end
166
+
167
+ it 'should contain an ID for the subject' do
168
+ results = person.class.search('dc\:relation.@id:' + subject.id)
169
+ expect(results.count).to eq 1
170
+ end
171
+ end
172
+
173
+ context 'with as_jsonld related' do
174
+ before do
175
+ person.class.index_for_search { as_jsonld related: true }
176
+ subject.class.index_for_search { as_jsonld related: true }
177
+ subject.save
178
+ Elasticsearch::Model.client.indices.flush
179
+ end
180
+
181
+ it 'should contain a embedded related object' do
182
+ results = subject.class.search('@graph.foaf\:name.@value:tove')
183
+ expect(results.count).to eq 1
184
+ expect(results.first._source.to_hash).to eq JSON.parse(subject.as_jsonld(related: true).to_json)
185
+ end
186
+
187
+ it 'should contain an embedded subject in the related object' do
188
+ results = person.class.search('@graph.dc\:title.@value:moomin*')
189
+ expect(results.count).to eq 1
190
+ expect(results.first._source.to_hash).to eq JSON.parse(person.as_jsonld(related: true).to_json)
191
+ end
192
+ end
193
+
194
+ context 'with as_framed_jsonld' do
195
+ before do
196
+ person.class.index_for_search { as_framed_jsonld }
197
+ subject.class.index_for_search { as_framed_jsonld }
198
+ subject.save
199
+ Elasticsearch::Model.client.indices.flush
200
+ end
201
+
202
+ it 'should contain a embedded related object' do
203
+ results = subject.class.search('dc\:creator.foaf\:name.@value:tove')
204
+ expect(results.count).to eq 1
205
+ expect(results.first._source.to_hash).to eq JSON.parse(subject.as_framed_jsonld.to_json)
206
+ end
207
+
208
+ it 'should contain an embedded subject in the related object' do
209
+ results = person.class.search('dc\:relation.dc\:title.@value:moomin*')
210
+ expect(results.count).to eq 1
211
+ expect(results.first._source.to_hash).to eq JSON.parse(person.as_framed_jsonld.to_json)
212
+ end
213
+ end
221
214
  end
222
-
223
- end
215
+ end
data/spec/spec_helper.rb CHANGED
@@ -3,6 +3,7 @@ Bundler.setup
3
3
 
4
4
  require 'ladder'
5
5
  require 'mongoid'
6
+ require 'awesome_print'
6
7
  require 'pry'
7
8
  require 'simplecov'
8
9
  SimpleCov.start
@@ -12,10 +13,10 @@ Dir['./spec/shared/**/*.rb'].each { |f| require f }
12
13
  RSpec.configure do |config|
13
14
  config.color = true
14
15
  config.tty = true
15
-
16
+
16
17
  # Uncomment the following line to get errors and backtrace for deprecation warnings
17
18
  # config.raise_errors_for_deprecations!
18
19
 
19
20
  # Use the specified formatter
20
21
  config.formatter = :documentation
21
- end
22
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ladder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - MJ Suhonos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-23 00:00:00.000000000 Z
11
+ date: 2015-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active-triples
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: awesome_print
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.6'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.6'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +142,42 @@ dependencies:
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: '3.1'
145
+ version: '3.2'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.2'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.29'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.29'
167
+ - !ruby/object:Gem::Dependency
168
+ name: semver
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '1.0'
132
174
  type: :development
133
175
  prerelease: false
134
176
  version_requirements: !ruby/object:Gem::Requirement
135
177
  requirements:
136
178
  - - "~>"
137
179
  - !ruby/object:Gem::Version
138
- version: '3.1'
180
+ version: '1.0'
139
181
  - !ruby/object:Gem::Dependency
140
182
  name: simplecov
141
183
  requirement: !ruby/object:Gem::Requirement
@@ -188,6 +230,7 @@ files:
188
230
  - ".gitignore"
189
231
  - ".rspec"
190
232
  - ".ruby-version"
233
+ - ".semver"
191
234
  - ".travis.yml"
192
235
  - Gemfile
193
236
  - LICENSE.txt
@@ -213,6 +256,7 @@ files:
213
256
  - spec/ladder/searchable/file_spec.rb
214
257
  - spec/ladder/searchable/resource_spec.rb
215
258
  - spec/shared/file.rb
259
+ - spec/shared/graph.jsonld
216
260
  - spec/shared/moomin.pdf
217
261
  - spec/shared/resource.rb
218
262
  - spec/shared/searchable/file.rb
@@ -250,6 +294,7 @@ test_files:
250
294
  - spec/ladder/searchable/file_spec.rb
251
295
  - spec/ladder/searchable/resource_spec.rb
252
296
  - spec/shared/file.rb
297
+ - spec/shared/graph.jsonld
253
298
  - spec/shared/moomin.pdf
254
299
  - spec/shared/resource.rb
255
300
  - spec/shared/searchable/file.rb