blacklight 5.0.0.pre1 → 5.0.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -4
  3. data/VERSION +1 -1
  4. data/app/assets/stylesheets/blacklight/_bookmark.css.scss +4 -0
  5. data/app/assets/stylesheets/blacklight/_catalog.css.scss +9 -13
  6. data/app/helpers/blacklight/blacklight_helper_behavior.rb +15 -9
  7. data/app/helpers/blacklight/catalog_helper_behavior.rb +8 -25
  8. data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
  9. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +1 -1
  10. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -2
  11. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -1
  12. data/app/views/bookmarks/index.html.erb +1 -1
  13. data/app/views/catalog/_did_you_mean.html.erb +1 -1
  14. data/app/views/catalog/_document.html.erb +4 -10
  15. data/app/views/catalog/{_document_header.html.erb → _index_header_default.html.erb} +6 -3
  16. data/app/views/catalog/_paginate_compact.html.erb +5 -0
  17. data/app/views/catalog/_show_header_default.html.erb +2 -0
  18. data/app/views/catalog/index.html.erb +1 -1
  19. data/app/views/catalog/show.html.erb +4 -10
  20. data/lib/blacklight.rb +0 -1
  21. data/lib/blacklight/configuration.rb +2 -2
  22. data/lib/blacklight/controller.rb +0 -1
  23. data/lib/blacklight/solr/document.rb +2 -0
  24. data/lib/blacklight/solr/document/schema_org.rb +7 -0
  25. data/lib/blacklight/solr_response.rb +4 -0
  26. data/lib/blacklight/user.rb +0 -6
  27. data/spec/controllers/application_controller_spec.rb +1 -2
  28. data/spec/controllers/bookmarks_controller_spec.rb +8 -9
  29. data/spec/controllers/catalog_controller_spec.rb +72 -73
  30. data/spec/controllers/saved_searches_controller_spec.rb +1 -2
  31. data/spec/controllers/search_history_controller_spec.rb +9 -10
  32. data/spec/features/search_pagination_spec.rb +1 -0
  33. data/spec/features/search_results_spec.rb +1 -0
  34. data/spec/features/search_spec.rb +1 -0
  35. data/spec/helpers/blacklight_helper_spec.rb +103 -93
  36. data/spec/helpers/catalog_helper_spec.rb +34 -21
  37. data/spec/helpers/facets_helper_spec.rb +41 -41
  38. data/spec/helpers/hash_as_hidden_fields_spec.rb +8 -9
  39. data/spec/helpers/render_constraints_helper_spec.rb +3 -3
  40. data/spec/helpers/search_history_constraints_helper_spec.rb +13 -14
  41. data/spec/lib/{blacklight_configurable_spec.rb → blacklight/configurable_spec.rb} +12 -14
  42. data/spec/lib/{blacklight_configuration_spec.rb → blacklight/configuration_spec.rb} +67 -69
  43. data/spec/lib/{facet_paginator_spec.rb → blacklight/facet_paginator_spec.rb} +13 -16
  44. data/spec/lib/{search_fields_spec.rb → blacklight/search_fields_spec.rb} +14 -15
  45. data/spec/lib/{blacklight_solr_document_dublin_core_spec.rb → blacklight/solr/document/dublin_core_spec.rb} +7 -8
  46. data/spec/lib/{blacklight_email_spec.rb → blacklight/solr/document/email_spec.rb} +5 -6
  47. data/spec/lib/{blacklight_solr_document_more_like_this_spec.rb → blacklight/solr/document/more_like_this_spec.rb} +5 -5
  48. data/spec/lib/{blacklight_sms_spec.rb → blacklight/solr/document/sms_spec.rb} +5 -6
  49. data/spec/lib/{blacklight_solr_document_spec.rb → blacklight/solr/document_spec.rb} +37 -39
  50. data/spec/lib/{solr_helper_spec.rb → blacklight/solr_helper_spec.rb} +183 -183
  51. data/spec/lib/{blacklight_solr_response_spec.rb → blacklight/solr_response_spec.rb} +20 -16
  52. data/spec/lib/{blacklight_user_spec.rb → blacklight/user_spec.rb} +3 -4
  53. data/spec/lib/blacklight_spec.rb +6 -7
  54. data/spec/lib/tasks/blacklight_task_spec.rb +2 -3
  55. data/spec/lib/utils_spec.rb +13 -14
  56. data/spec/models/bookmark_spec.rb +4 -4
  57. data/spec/models/record_mailer_spec.rb +15 -15
  58. data/spec/models/search_spec.rb +7 -7
  59. data/spec/models/solr_document_spec.rb +4 -4
  60. data/spec/routing/catalog_routing_spec.rb +12 -12
  61. data/spec/spec_helper.rb +1 -3
  62. data/spec/test_app_templates/Gemfile.extra +1 -2
  63. data/spec/views/catalog/_constraints_element.html.erb_spec.rb +12 -13
  64. data/spec/views/catalog/_document.html.erb_spec.rb +19 -2
  65. data/spec/views/catalog/_document_list.html.erb_spec.rb +0 -1
  66. data/spec/views/catalog/_facets.html.erb_spec.rb +5 -5
  67. data/spec/views/catalog/_index_default.erb_spec.rb +10 -11
  68. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +45 -0
  69. data/spec/views/catalog/_search_header.erb_spec.rb +0 -1
  70. data/spec/views/catalog/_show_default.erb_spec.rb +10 -11
  71. data/spec/views/catalog/_show_sidebar.erb_spec.rb +2 -3
  72. data/spec/views/catalog/index.atom.builder_spec.rb +26 -27
  73. data/spec/views/catalog/index.html.erb_spec.rb +1 -1
  74. data/spec/views/catalog/show.html.erb_spec.rb +56 -0
  75. data/tasks/blacklight.rake +1 -1
  76. metadata +65 -64
  77. data/lib/blacklight/legacy_controller_methods.rb +0 -26
  78. data/spec/rcov.opts +0 -3
  79. data/spec/support/assert_difference.rb +0 -17
@@ -1,5 +1,4 @@
1
- # -*- encoding : utf-8 -*-
2
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
3
2
 
4
3
  describe SavedSearchesController do
5
4
  include Devise::TestHelpers
@@ -1,5 +1,4 @@
1
- # -*- encoding : utf-8 -*-
2
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
3
2
 
4
3
  describe SearchHistoryController do
5
4
  include Devise::TestHelpers
@@ -15,26 +14,26 @@ describe SearchHistoryController do
15
14
  session[:history] = [@one.id, @three.id]
16
15
  get :index
17
16
  @searches = assigns(:searches)
18
- @searches.length.should == 2
19
- @searches.should include(@one)
20
- @searches.should include(@three)
21
- @searches.should_not include(@two)
17
+ expect(@searches).to have(2).searches
18
+ expect(@searches).to include(@one)
19
+ expect(@searches).to include(@three)
20
+ expect(@searches).to_not include(@two)
22
21
  end
23
22
 
24
23
  it "should tolerate bad ids in session" do
25
24
  session[:history] = [@one.id, @three.id, "NOT_IN_DB"]
26
25
  get :index
27
26
  @searches = assigns(:searches)
28
- @searches.length.should == 2
29
- @searches.should include(@one)
30
- @searches.should include(@three)
27
+ expect(@searches).to have(2).searches
28
+ expect(@searches).to include(@one)
29
+ expect(@searches).to include(@three)
31
30
  end
32
31
 
33
32
  it "should not fetch any searches if there is no history" do
34
33
  session[:history] = []
35
34
  get :index
36
35
  @searches = assigns(:searches)
37
- @searches.length.should == 0
36
+ expect(@searches).to be_empty
38
37
  end
39
38
  end
40
39
 
@@ -1,4 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  describe "Search Pagination" do
@@ -1,4 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  describe "Search Results" do
@@ -1,4 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  describe "Search Page" do
@@ -1,4 +1,3 @@
1
- # -*- coding: UTF-8 -*-
2
1
  require 'spec_helper'
3
2
 
4
3
  def exportable_record
@@ -94,10 +93,10 @@ describe BlacklightHelper do
94
93
  it "should use the Rails application config application_name if available" do
95
94
  Rails.application.config.stub(:application_name => 'asdf')
96
95
  Rails.application.config.should_receive(:respond_to?).with(:application_name).and_return(true)
97
- application_name.should == 'asdf'
96
+ expect(application_name).to eq 'asdf'
98
97
  end
99
98
  it "should default to 'Blacklight'" do
100
- application_name.should == "Blacklight"
99
+ expect(application_name).to eq "Blacklight"
101
100
  end
102
101
  end
103
102
 
@@ -108,18 +107,18 @@ describe BlacklightHelper do
108
107
  it "should build a link tag to catalog using session[:search] for query params" do
109
108
  helper.stub(:current_search_session).and_return double(:query_params => query_params)
110
109
  tag = helper.link_back_to_catalog
111
- tag.should =~ /q=query/
112
- tag.should =~ /f=facets/
113
- tag.should =~ /per_page=10/
114
- tag.should =~ /page=2/
110
+ expect(tag).to match /q=query/
111
+ expect(tag).to match /f=facets/
112
+ expect(tag).to match /per_page=10/
113
+ expect(tag).to match /page=2/
115
114
  end
116
115
 
117
116
  it "should build a link tag to bookmarks using session[:search] for query params" do
118
117
  helper.stub(:current_search_session).and_return double(:query_params => bookmarks_query_params)
119
118
  tag = helper.link_back_to_catalog
120
- tag.should =~ /Back to Bookmarks/
121
- tag.should =~ /\/bookmarks/
122
- tag.should =~ /page=2/
119
+ expect(tag).to match /Back to Bookmarks/
120
+ expect(tag).to match /\/bookmarks/
121
+ expect(tag).to match /page=2/
123
122
  end
124
123
 
125
124
  describe "when an alternate scope is passed in" do
@@ -129,11 +128,11 @@ describe BlacklightHelper do
129
128
  helper.stub(:current_search_session).and_return double(:query_params => query_params)
130
129
  expect(my_engine).to receive(:url_for).and_return(url_for(query_params))
131
130
  tag = helper.link_back_to_catalog(route_set: my_engine)
132
- tag.should =~ /Back to Search/
133
- tag.should =~ /q=query/
134
- tag.should =~ /f=facets/
135
- tag.should =~ /per_page=10/
136
- tag.should =~ /page=2/
131
+ expect(tag).to match /Back to Search/
132
+ expect(tag).to match /q=query/
133
+ expect(tag).to match /f=facets/
134
+ expect(tag).to match /per_page=10/
135
+ expect(tag).to match /page=2/
137
136
  end
138
137
  end
139
138
  end
@@ -143,28 +142,28 @@ describe BlacklightHelper do
143
142
  query = "brilliant"
144
143
  self.should_receive(:params).and_return({})
145
144
  tag = link_to_query(query)
146
- tag.should =~ /q=#{query}/
147
- tag.should =~ />#{query}<\/a>/
145
+ expect(tag).to match /q=#{query}/
146
+ expect(tag).to match />#{query}<\/a>/
148
147
  end
149
148
  it "should build a link tag to catalog using query string and other existing params" do
150
149
  query = "wonderful"
151
150
  self.should_receive(:params).and_return({:qt => "title_search", :per_page => "50"})
152
151
  tag = link_to_query(query)
153
- tag.should =~ /qt=title_search/
154
- tag.should =~ /per_page=50/
152
+ expect(tag).to match /qt=title_search/
153
+ expect(tag).to match /per_page=50/
155
154
  end
156
155
  it "should ignore existing :page param" do
157
156
  query = "yes"
158
157
  self.should_receive(:params).and_return({:page => "2", :qt => "author_search"})
159
158
  tag = link_to_query(query)
160
- tag.should =~ /qt=author_search/
161
- tag.should_not =~ /page/
159
+ expect(tag).to match /qt=author_search/
160
+ expect(tag).to_not match /page/
162
161
  end
163
162
  it "should be html_safe" do
164
163
  query = "brilliant"
165
164
  self.should_receive(:params).and_return({:page => "2", :qt => "author_search"})
166
165
  tag = link_to_query(query)
167
- tag.html_safe?.should == true
166
+ expect(tag).to be_html_safe
168
167
  end
169
168
  end
170
169
 
@@ -175,46 +174,45 @@ describe BlacklightHelper do
175
174
 
176
175
  it "should default to using the controller's params" do
177
176
  result = params_for_search
178
- result.should == params
179
- params.object_id.should_not == result.object_id
177
+ expect(result).to eq params
178
+ expect(params.object_id).to_not eq result.object_id
180
179
  end
181
180
 
182
181
  it "should let you pass in params to use" do
183
182
  source_params = { :q => 'query'}
184
183
  result = params_for_search(:params => source_params )
185
- source_params.should == result
186
- source_params.object_id.should_not == result.object_id
184
+ expect(source_params).to eq result
185
+ expect(source_params.object_id).to_not eq result.object_id
187
186
  end
188
187
 
189
188
  it "should not return blacklisted elements" do
190
189
  source_params = { :action => 'action', :controller => 'controller', :id => "id", :commit => 'commit'}
191
190
  result = params_for_search(:params => source_params )
192
- result.keys.should_not include(:action, :controller, :commit, :id)
193
-
191
+ expect(result.keys).to_not include(:action, :controller, :commit, :id)
194
192
  end
195
193
 
196
194
  it "should adjust the current page if the per_page changes" do
197
195
  source_params = { :per_page => 20, :page => 5}
198
196
  result = params_for_search(:params => source_params, :per_page => 100)
199
- result[:page].should == 1
197
+ expect(result[:page]).to eq 1
200
198
  end
201
199
 
202
200
  it "should not adjust the current page if the per_page is the same as it always was" do
203
201
  source_params = { :per_page => 20, :page => 5}
204
202
  result = params_for_search(:params => source_params, :per_page => 20)
205
- result[:page].should == 5
203
+ expect(result[:page]).to eq 5
206
204
  end
207
205
 
208
206
  it "should adjust the current page if the sort changes" do
209
207
  source_params = { :sort => 'field_a', :page => 5}
210
208
  result = params_for_search(:params => source_params, :sort => 'field_b')
211
- result[:page].should == 1
209
+ expect(result[:page]).to eq 1
212
210
  end
213
211
 
214
212
  it "should not adjust the current page if the sort is the same as it always was" do
215
213
  source_params = { :sort => 'field_a', :page => 5}
216
214
  result = params_for_search(:params => source_params, :sort => 'field_a')
217
- result[:page].should == 5
215
+ expect(result[:page]).to eq 5
218
216
  end
219
217
 
220
218
  describe "omit keys parameter" do
@@ -223,21 +221,21 @@ describe BlacklightHelper do
223
221
  result = params_for_search(:params => source_params, :omit_keys => [:a, :b] )
224
222
 
225
223
  result.keys.should_not include(:a, :b)
226
- result[:c].should == 3
224
+ expect(result[:c]).to eq 3
227
225
  end
228
226
 
229
227
  it "should remove keys if a key/value pair was passed and no values are left for that key" do
230
228
  source_params = { :f => ['a']}
231
229
  result = params_for_search(:params => source_params, :omit_keys => [{:f => 'a' }])
232
- result.keys.should_not include(:f)
230
+ expect(result.keys).to_not include(:f)
233
231
  end
234
232
 
235
233
  it "should only remove keys when a key/value pair is based that are in that pair" do
236
234
 
237
235
  source_params = { :f => ['a', 'b']}
238
236
  result = params_for_search(:params => source_params, :omit_keys => [{:f => 'a' }])
239
- result[:f].should_not include('a')
240
- result[:f].should include('b')
237
+ expect(result[:f]).to_not include('a')
238
+ expect(result[:f]).to include('b')
241
239
  end
242
240
  end
243
241
 
@@ -249,7 +247,7 @@ describe BlacklightHelper do
249
247
  end
250
248
  describe "for default arguments" do
251
249
  it "should default to omitting :page" do
252
- search_as_hidden_fields.should_not have_selector("input[name='page']")
250
+ expect(search_as_hidden_fields).to_not have_selector("input[name='page']")
253
251
  end
254
252
  end
255
253
  end
@@ -261,7 +259,7 @@ describe BlacklightHelper do
261
259
  @controller.stub(:controller_name).and_return("123456")
262
260
  @controller.stub(:action_name).and_return("abcdef")
263
261
 
264
- render_body_class.split(' ').should include('blacklight-123456')
262
+ expect(render_body_class.split(' ')).to include('blacklight-123456')
265
263
  end
266
264
 
267
265
  it "should include a serialization of the current action name" do
@@ -269,7 +267,7 @@ describe BlacklightHelper do
269
267
  @controller.stub(:controller_name).and_return("123456")
270
268
  @controller.stub(:action_name).and_return("abcdef")
271
269
 
272
- render_body_class.split(' ').should include('blacklight-123456-abcdef')
270
+ expect(render_body_class.split(' ')).to include('blacklight-123456-abcdef')
273
271
  end
274
272
  end
275
273
 
@@ -278,12 +276,12 @@ describe BlacklightHelper do
278
276
  it "should consist of the show heading field when available" do
279
277
  @document = SolrDocument.new('title_display' => "A Fake Document")
280
278
 
281
- document_heading.should == "A Fake Document"
279
+ expect(document_heading).to eq "A Fake Document"
282
280
  end
283
281
 
284
282
  it "should fallback on the document id if no title is available" do
285
283
  @document = SolrDocument.new(:id => '123456')
286
- document_heading.should == '123456'
284
+ expect(document_heading).to eq '123456'
287
285
  end
288
286
  end
289
287
 
@@ -291,36 +289,43 @@ describe BlacklightHelper do
291
289
  it "should consist of #document_heading wrapped in a <h1>" do
292
290
  @document = SolrDocument.new('title_display' => "A Fake Document")
293
291
 
294
- render_document_heading.should have_selector("h4", :text => "A Fake Document", :count => 1)
295
- render_document_heading.html_safe?.should == true
292
+ expect(render_document_heading).to have_selector("h4", :text => "A Fake Document", :count => 1)
293
+ expect(render_document_heading).to be_html_safe
294
+ end
295
+
296
+ it "should have a schema.org itemprop for name" do
297
+ @document = SolrDocument.new('title_display' => "A Fake Document")
298
+
299
+ expect(render_document_heading).to have_selector("h4[@itemprop='name']", :text => "A Fake Document")
296
300
  end
301
+
297
302
  it "should join the values if it is an array" do
298
303
  @document = SolrDocument.new('title_display' => ["A Fake Document", 'Something Else'])
299
304
 
300
- render_document_heading.should have_selector("h4", :text => "A Fake Document, Something Else", :count => 1)
301
- render_document_heading.html_safe?.should == true
305
+ expect(render_document_heading).to have_selector("h4", :text => "A Fake Document, Something Else", :count => 1)
306
+ expect(render_document_heading).to be_html_safe
302
307
  end
303
308
  end
304
309
 
305
310
  describe "document_show_html_title" do
306
311
  it "should join the values if it is an array" do
307
312
  @document = SolrDocument.new('title_display' => ["A Fake Document", 'Something Else'])
308
- document_show_html_title.should == "A Fake Document, Something Else"
313
+ expect(document_show_html_title).to eq "A Fake Document, Something Else"
309
314
  end
310
315
  end
311
316
 
312
317
  describe "document_index_view_type" do
313
318
  it "should default to 'list'" do
314
- document_index_view_type.should == 'list'
319
+ expect(document_index_view_type).to eq 'list'
315
320
  end
316
321
 
317
322
  it "should pluck values out of params" do
318
323
  blacklight_config.stub(:document_index_view_types) { ['list', 'asdf'] }
319
324
  params[:view] = 'asdf'
320
- document_index_view_type.should == 'asdf'
325
+ expect(document_index_view_type).to eq 'asdf'
321
326
 
322
327
  params[:view] = 'not_in_list'
323
- document_index_view_type.should == 'list'
328
+ expect(document_index_view_type).to eq 'list'
324
329
  end
325
330
  end
326
331
 
@@ -342,26 +347,26 @@ describe BlacklightHelper do
342
347
 
343
348
  describe "document_partial_name" do
344
349
  it "should default to 'default' when a format blank" do
345
- document_partial_name({}).should == "default"
350
+ expect(document_partial_name({})).to eq "default"
346
351
  end
347
352
  it "should handle normal formats correctly" do
348
- document_partial_name({"format" => "myformat"}).should == "myformat"
353
+ expect(document_partial_name({"format" => "myformat"})).to eq "myformat"
349
354
  end
350
355
  it "should handle spaces correctly" do
351
- document_partial_name({"format" => "my format"}).should == "my_format"
356
+ expect(document_partial_name({"format" => "my format"})).to eq "my_format"
352
357
  end
353
358
  it "should handle capitalization correctly" do
354
- document_partial_name({"format" => "MyFormat"}).should == "myformat"
359
+ expect(document_partial_name({"format" => "MyFormat"})).to eq "myformat"
355
360
  end
356
361
  it "should handle puncuation correctly" do
357
- document_partial_name({"format" => "My.Format"}).should == "my_format"
362
+ expect(document_partial_name({"format" => "My.Format"})).to eq "my_format"
358
363
  end
359
364
  it "should handle multi-valued fields correctly" do
360
- document_partial_name({"format" => ["My Format", "My OtherFormat"]}).should == "my_format_my_otherformat"
365
+ expect(document_partial_name({"format" => ["My Format", "My OtherFormat"]})).to eq "my_format_my_otherformat"
361
366
  end
362
367
  it "should remove - characters because they will throw errors" do
363
- document_partial_name({"format" => "My-Format"}).should == "my_format"
364
- document_partial_name({"format" => ["My-Format",["My Other-Format"]]}).should == "my_format_my_other_format"
368
+ expect(document_partial_name({"format" => "My-Format"})).to eq "my_format"
369
+ expect(document_partial_name({"format" => ["My-Format",["My Other-Format"]]})).to eq "my_format_my_other_format"
365
370
  end
366
371
  end
367
372
 
@@ -369,45 +374,46 @@ describe BlacklightHelper do
369
374
  it "should consist of the document title wrapped in a <a>" do
370
375
  data = {'id'=>'123456','title_display'=>['654321'] }
371
376
  @document = SolrDocument.new(data)
372
- link_to_document(@document, { :label => :title_display }).should have_selector("a", :text => '654321', :count => 1)
377
+ expect(link_to_document(@document, { :label => :title_display })).to have_selector("a", :text => '654321', :count => 1)
373
378
  end
379
+
374
380
  it "should accept and return a string label" do
375
381
  data = {'id'=>'123456','title_display'=>['654321'] }
376
382
  @document = SolrDocument.new(data)
377
- link_to_document(@document, { :label => "title_display" }).should have_selector("a", :text => 'title_display', :count => 1)
383
+ expect(link_to_document(@document, { :label => "title_display" })).to have_selector("a", :text => 'title_display', :count => 1)
378
384
  end
379
385
 
380
386
  it "should accept and return a Proc" do
381
387
  data = {'id'=>'123456','title_display'=>['654321'] }
382
388
  @document = SolrDocument.new(data)
383
- link_to_document(@document, { :label => Proc.new { |doc, opts| doc.get(:id) + ": " + doc.get(:title_display) } }).should have_selector("a", :text => '123456: 654321', :count => 1)
389
+ expect(link_to_document(@document, { :label => Proc.new { |doc, opts| doc.get(:id) + ": " + doc.get(:title_display) } })).to have_selector("a", :text => '123456: 654321', :count => 1)
384
390
  end
385
391
  it "should return id when label is missing" do
386
392
  data = {'id'=>'123456'}
387
393
  @document = SolrDocument.new(data)
388
- link_to_document(@document, { :label => :title_display }).should have_selector("a", :text => '123456', :count => 1)
394
+ expect(link_to_document(@document, { :label => :title_display })).to have_selector("a", :text => '123456', :count => 1)
389
395
  end
390
396
 
391
397
  it "should be html safe" do
392
398
  data = {'id'=>'123456'}
393
399
  @document = SolrDocument.new(data)
394
- link_to_document(@document, { :label => :title_display }).html_safe?.should == true
400
+ expect(link_to_document(@document, { :label => :title_display })).to be_html_safe
395
401
  end
396
402
 
397
403
  it "should convert the counter parameter into a data- attribute" do
398
404
  data = {'id'=>'123456','title_display'=>['654321']}
399
405
  @document = SolrDocument.new(data)
400
- link_to_document(@document, { :label => :title_display, :counter => 5 }).should =~ /data-counter="5"/
406
+ expect(link_to_document(@document, { :label => :title_display, :counter => 5 })).to match /data-counter="5"/
401
407
  end
402
408
 
403
409
  it "passes on the title attribute to the link_to_with_data method" do
404
410
  @document = SolrDocument.new('id'=>'123456')
405
- link_to_document(@document,:label=>"Some crazy long label...",:title=>"Some crazy longer label").should match(/title=\"Some crazy longer label\"/)
411
+ expect(link_to_document(@document,:label=>"Some crazy long label...",:title=>"Some crazy longer label")).to match(/title=\"Some crazy longer label\"/)
406
412
  end
407
413
 
408
414
  it "doesn't add an erroneous title attribute if one isn't provided" do
409
415
  @document = SolrDocument.new('id'=>'123456')
410
- link_to_document(@document,:label=>"Some crazy long label...").should_not match(/title=/)
416
+ expect(link_to_document(@document,:label=>"Some crazy long label...")).to_not match(/title=/)
411
417
  end
412
418
  end
413
419
 
@@ -444,11 +450,11 @@ describe BlacklightHelper do
444
450
  Capybara.ignore_hidden_elements = false
445
451
  @document.export_formats.each_pair do |format, spec|
446
452
  response.should have_selector("link[href$='.#{ format }']") do |matches|
447
- matches.length.should == 1
453
+ expect(matches).to have(1).match
448
454
  tag = matches[0]
449
- tag.attributes["rel"].value.should == "alternate"
450
- tag.attributes["title"].value.should == format.to_s
451
- tag.attributes["href"].value.should === mock_document_app_helper_url(@document, :format =>format)
455
+ expect(tag.attributes["rel"].value).to eq "alternate"
456
+ expect(tag.attributes["title"].value).to eq format.to_s
457
+ expect(tag.attributes["href"].value).to eq mock_document_app_helper_url(@document, :format =>format)
452
458
  end
453
459
  end
454
460
  Capybara.ignore_hidden_elements = tmp_value
@@ -457,7 +463,7 @@ describe BlacklightHelper do
457
463
  response = render_link_rel_alternates(@document, :unique => true)
458
464
  tmp_value = Capybara.ignore_hidden_elements
459
465
  Capybara.ignore_hidden_elements = false
460
- response.should have_selector("link[type='application/weird']", :count => 1)
466
+ expect(response).to have_selector("link[type='application/weird']", :count => 1)
461
467
  Capybara.ignore_hidden_elements = tmp_value
462
468
  end
463
469
  it "excludes formats from :exclude" do
@@ -465,13 +471,13 @@ describe BlacklightHelper do
465
471
 
466
472
  tmp_value = Capybara.ignore_hidden_elements
467
473
  Capybara.ignore_hidden_elements = false
468
- response.should_not have_selector("link[href$='.weird_dup']")
474
+ expect(response).to_not have_selector("link[href$='.weird_dup']")
469
475
  Capybara.ignore_hidden_elements = tmp_value
470
476
  end
471
477
 
472
478
  it "should be html safe" do
473
479
  response = render_link_rel_alternates(@document)
474
- response.html_safe?.should == true
480
+ expect(response).to be_html_safe
475
481
  end
476
482
  end
477
483
 
@@ -494,13 +500,13 @@ describe BlacklightHelper do
494
500
  describe "render_index_doc_actions" do
495
501
  it "should render partials" do
496
502
  response = helper.render_index_doc_actions(@document)
497
- response.should have_selector(".bookmark_toggle")
503
+ expect(response).to have_selector(".bookmark_toggle")
498
504
  end
499
505
  end
500
506
  describe "render_show_doc_actions" do
501
507
  it "should render partials" do
502
508
  response = helper.render_show_doc_actions(@document)
503
- response.should have_selector(".bookmark_toggle")
509
+ expect(response).to have_selector(".bookmark_toggle")
504
510
  end
505
511
  end
506
512
  end
@@ -521,7 +527,7 @@ describe BlacklightHelper do
521
527
  doc = double()
522
528
  doc.should_not_receive(:get).with('asdf', :sep => nil)
523
529
  value = helper.render_index_field_value :value => 'asdf', :document => doc, :field => 'asdf'
524
- value.should == 'asdf'
530
+ expect(value).to eq 'asdf'
525
531
  end
526
532
 
527
533
  it "should check for a helper method to call" do
@@ -529,21 +535,21 @@ describe BlacklightHelper do
529
535
  doc.should_not_receive(:get).with('asdf', :sep => nil)
530
536
  helper.stub(:render_asdf_index_field).and_return('custom asdf value')
531
537
  value = helper.render_index_field_value :document => doc, :field => 'asdf'
532
- value.should == 'custom asdf value'
538
+ expect(value).to eq 'custom asdf value'
533
539
  end
534
540
 
535
541
  it "should check for a link_to_search" do
536
542
  doc = double()
537
543
  doc.should_receive(:get).with('link_to_search_true', :sep => nil).and_return('x')
538
544
  value = helper.render_index_field_value :document => doc, :field => 'link_to_search_true'
539
- value.should == helper.link_to("x", helper.search_action_url(:f => { :link_to_search_true => ['x'] }))
545
+ expect(value).to eq helper.link_to("x", helper.search_action_url(:f => { :link_to_search_true => ['x'] }))
540
546
  end
541
547
 
542
548
  it "should check for a link_to_search with a field name" do
543
549
  doc = double()
544
550
  doc.should_receive(:get).with('link_to_search_named', :sep => nil).and_return('x')
545
551
  value = helper.render_index_field_value :document => doc, :field => 'link_to_search_named'
546
- value.should == helper.link_to("x", helper.search_action_url(:f => { :some_field => ['x'] }))
552
+ expect(value).to eq helper.link_to("x", helper.search_action_url(:f => { :some_field => ['x'] }))
547
553
  end
548
554
 
549
555
  it "should gracefully handle when no highlight field is available" do
@@ -551,7 +557,7 @@ describe BlacklightHelper do
551
557
  doc.should_not_receive(:get)
552
558
  doc.should_receive(:has_highlight_field?).and_return(false)
553
559
  value = helper.render_index_field_value :document => doc, :field => 'highlight'
554
- value.should be_blank
560
+ expect(value).to be_blank
555
561
  end
556
562
 
557
563
  it "should check for a highlighted field" do
@@ -560,21 +566,21 @@ describe BlacklightHelper do
560
566
  doc.should_receive(:has_highlight_field?).and_return(true)
561
567
  doc.should_receive(:highlight_field).with('highlight').and_return(['<em>highlight</em>'.html_safe])
562
568
  value = helper.render_index_field_value :document => doc, :field => 'highlight'
563
- value.should == '<em>highlight</em>'
569
+ expect(value).to eq '<em>highlight</em>'
564
570
  end
565
571
 
566
572
  it "should check the document field value" do
567
573
  doc = double()
568
574
  doc.should_receive(:get).with('qwer', :sep => nil).and_return('document qwer value')
569
575
  value = helper.render_index_field_value :document => doc, :field => 'qwer'
570
- value.should == 'document qwer value'
576
+ expect(value).to eq 'document qwer value'
571
577
  end
572
578
 
573
579
  it "should work with index fields that aren't explicitly defined" do
574
580
  doc = double()
575
581
  doc.should_receive(:get).with('mnbv', :sep => nil).and_return('document mnbv value')
576
582
  value = helper.render_index_field_value :document => doc, :field => 'mnbv'
577
- value.should == 'document mnbv value'
583
+ expect(value).to eq 'document mnbv value'
578
584
  end
579
585
  end
580
586
 
@@ -596,7 +602,7 @@ describe BlacklightHelper do
596
602
  doc.should_not_receive(:get).with('asdf', :sep => nil)
597
603
  helper.should_not_receive(:render_asdf_document_show_field)
598
604
  value = helper.render_document_show_field_value :value => 'asdf', :document => doc, :field => 'asdf'
599
- value.should == 'asdf'
605
+ expect(value).to eq 'asdf'
600
606
  end
601
607
 
602
608
  it "should check for a helper method to call" do
@@ -604,21 +610,21 @@ describe BlacklightHelper do
604
610
  doc.should_not_receive(:get).with('asdf', :sep => nil)
605
611
  helper.stub(:render_asdf_document_show_field).and_return('custom asdf value')
606
612
  value = helper.render_document_show_field_value :document => doc, :field => 'asdf'
607
- value.should == 'custom asdf value'
613
+ expect(value).to eq 'custom asdf value'
608
614
  end
609
615
 
610
616
  it "should check for a link_to_search" do
611
617
  doc = double()
612
618
  doc.should_receive(:get).with('link_to_search_true', :sep => nil).and_return('x')
613
619
  value = helper.render_document_show_field_value :document => doc, :field => 'link_to_search_true'
614
- value.should == helper.link_to("x", helper.search_action_url(:f => { :link_to_search_true => ['x'] }))
620
+ expect(value).to eq helper.link_to("x", helper.search_action_url(:f => { :link_to_search_true => ['x'] }))
615
621
  end
616
622
 
617
623
  it "should check for a link_to_search with a field name" do
618
624
  doc = double()
619
625
  doc.should_receive(:get).with('link_to_search_named', :sep => nil).and_return('x')
620
626
  value = helper.render_document_show_field_value :document => doc, :field => 'link_to_search_named'
621
- value.should == helper.link_to("x", helper.search_action_url(:f => { :some_field => ['x'] }))
627
+ expect(value).to eq helper.link_to("x", helper.search_action_url(:f => { :some_field => ['x'] }))
622
628
  end
623
629
 
624
630
  it "should gracefully handle when no highlight field is available" do
@@ -626,7 +632,7 @@ describe BlacklightHelper do
626
632
  doc.should_not_receive(:get)
627
633
  doc.should_receive(:has_highlight_field?).and_return(false)
628
634
  value = helper.render_document_show_field_value :document => doc, :field => 'highlight'
629
- value.should be_blank
635
+ expect(value).to be_blank
630
636
  end
631
637
 
632
638
  it "should check for a highlighted field" do
@@ -635,7 +641,7 @@ describe BlacklightHelper do
635
641
  doc.should_receive(:has_highlight_field?).and_return(true)
636
642
  doc.should_receive(:highlight_field).with('highlight').and_return(['<em>highlight</em>'.html_safe])
637
643
  value = helper.render_document_show_field_value :document => doc, :field => 'highlight'
638
- value.should == '<em>highlight</em>'
644
+ expect(value).to eq '<em>highlight</em>'
639
645
  end
640
646
 
641
647
 
@@ -643,14 +649,14 @@ describe BlacklightHelper do
643
649
  doc = double()
644
650
  doc.should_receive(:get).with('qwer', :sep => nil).and_return('document qwer value')
645
651
  value = helper.render_document_show_field_value :document => doc, :field => 'qwer'
646
- value.should == 'document qwer value'
652
+ expect(value).to eq 'document qwer value'
647
653
  end
648
654
 
649
655
  it "should work with show fields that aren't explicitly defined" do
650
656
  doc = double()
651
657
  doc.should_receive(:get).with('mnbv', :sep => nil).and_return('document mnbv value')
652
658
  value = helper.render_document_show_field_value :document => doc, :field => 'mnbv'
653
- value.should == 'document mnbv value'
659
+ expect(value).to eq 'document mnbv value'
654
660
  end
655
661
  end
656
662
 
@@ -677,7 +683,7 @@ describe BlacklightHelper do
677
683
  doc = double()
678
684
  doc.stub(:has?).with('asdf').and_return(true)
679
685
  field_config = double(:field => 'asdf')
680
- helper.should_render_show_field?(doc, field_config).should == true
686
+ expect(helper.should_render_show_field?(doc, field_config)).to be_true
681
687
  end
682
688
 
683
689
  it "should if the document has a highlight field value" do
@@ -685,7 +691,7 @@ describe BlacklightHelper do
685
691
  doc.stub(:has?).with('asdf').and_return(false)
686
692
  doc.stub(:has_highlight_field?).with('asdf').and_return(true)
687
693
  field_config = double(:field => 'asdf', :highlight => true)
688
- helper.should_render_show_field?(doc, field_config).should == true
694
+ expect(helper.should_render_show_field?(doc, field_config)).to be_true
689
695
  end
690
696
  end
691
697
 
@@ -718,7 +724,11 @@ describe BlacklightHelper do
718
724
  end
719
725
 
720
726
  it "should use the separator from the Blacklight field configuration by default" do
721
- expect(helper.render_field_value(['c', 'd'], double(:separator => '; '))).to eq "c; d"
727
+ expect(helper.render_field_value(['c', 'd'], double(:separator => '; ', :itemprop => nil))).to eq "c; d"
728
+ end
729
+
730
+ it "should include schema.org itemprop attributes" do
731
+ expect(helper.render_field_value('a', double(:separator => nil, :itemprop => 'some-prop'))).to have_selector("span[@itemprop='some-prop']", :text => "a")
722
732
  end
723
733
  end
724
734
  end