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
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
- require 'blacklight'
1
+ require 'spec_helper'
3
2
 
4
3
  describe Blacklight::SolrResponse do
5
4
 
@@ -11,21 +10,21 @@ describe Blacklight::SolrResponse do
11
10
  let(:r) { create_response }
12
11
 
13
12
  it 'should create a valid response' do
14
- r.should respond_to(:header)
13
+ expect(r).to respond_to(:header)
15
14
  end
16
15
 
17
16
  it 'should have accurate pagination numbers' do
18
- r.rows.should == 11
19
- r.total.should == 26
20
- r.start.should == 0
17
+ expect(r.rows).to eq 11
18
+ expect(r.total).to eq 26
19
+ expect(r.start).to eq 0
21
20
  end
22
21
 
23
22
  it 'should create a valid response class' do
24
- r.should respond_to(:response)
25
- r.docs.size.should == 11
26
- r.params[:echoParams].should == 'EXPLICIT'
23
+ expect(r).to respond_to(:response)
24
+ expect(r.docs).to have(11).docs
25
+ expect(r.params[:echoParams]).to eq 'EXPLICIT'
27
26
 
28
- r.should be_a(Blacklight::SolrResponse::Facets)
27
+ expect(r).to be_a(Blacklight::SolrResponse::Facets)
29
28
  end
30
29
 
31
30
  it 'should provide facet helpers' do
@@ -45,13 +44,13 @@ describe Blacklight::SolrResponse do
45
44
  item.value + ' - ' + item.hits.to_s
46
45
  end.join(', ')
47
46
 
48
- received.should == expected
47
+ expect(received).to eq expected
49
48
 
50
49
  r.facets.each do |facet|
51
- facet.respond_to?(:name).should == true
50
+ expect(facet).to respond_to :name
52
51
  facet.items.each do |item|
53
- item.respond_to?(:value).should == true
54
- item.respond_to?(:hits).should == true
52
+ expect(item).to respond_to :value
53
+ expect(item).to respond_to :hits
55
54
  end
56
55
  end
57
56
 
@@ -70,12 +69,11 @@ describe Blacklight::SolrResponse do
70
69
  end
71
70
 
72
71
  it "should provide a model name helper" do
73
- first_doc_model_name = 'xyz'
72
+ first_doc_model_name = double(:human => 'xyz')
74
73
 
75
74
  r.docs.first.stub(:model_name).and_return first_doc_model_name
76
75
 
77
76
  expect(r.model_name).to eq first_doc_model_name
78
-
79
77
  end
80
78
 
81
79
  describe "FacetItem" do
@@ -178,6 +176,12 @@ describe Blacklight::SolrResponse do
178
176
  r.more_like(double(:id => '79930185')).should have(2).items
179
177
  end
180
178
 
179
+ it "should be empty when the response has no results" do
180
+ r = Blacklight::SolrResponse.new({}, {})
181
+ r.stub(:total => 0)
182
+ expect(r).to be_empty
183
+ end
184
+
181
185
  def mock_query_response
182
186
  %({'responseHeader'=>{'status'=>0,'QTime'=>5,'params'=>{'facet.limit'=>'10','wt'=>'ruby','rows'=>'11','facet'=>'true','facet.field'=>['cat','manu'],'echoParams'=>'EXPLICIT','q'=>'*:*','facet.sort'=>'true'}},'response'=>{'numFound'=>26,'start'=>0,'docs'=>[{'id'=>'SP2514N','inStock'=>true,'manu'=>'Samsung Electronics Co. Ltd.','name'=>'Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133','popularity'=>6,'price'=>92.0,'sku'=>'SP2514N','timestamp'=>'2009-03-20T14:42:49.795Z','cat'=>['electronics','hard drive'],'spell'=>['Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133'],'features'=>['7200RPM, 8MB cache, IDE Ultra ATA-133','NoiseGuard, SilentSeek technology, Fluid Dynamic Bearing (FDB) motor']},{'id'=>'6H500F0','inStock'=>true,'manu'=>'Maxtor Corp.','name'=>'Maxtor DiamondMax 11 - hard drive - 500 GB - SATA-300','popularity'=>6,'price'=>350.0,'sku'=>'6H500F0','timestamp'=>'2009-03-20T14:42:49.877Z','cat'=>['electronics','hard drive'],'spell'=>['Maxtor DiamondMax 11 - hard drive - 500 GB - SATA-300'],'features'=>['SATA 3.0Gb/s, NCQ','8.5ms seek','16MB cache']},{'id'=>'F8V7067-APL-KIT','inStock'=>false,'manu'=>'Belkin','name'=>'Belkin Mobile Power Cord for iPod w/ Dock','popularity'=>1,'price'=>19.95,'sku'=>'F8V7067-APL-KIT','timestamp'=>'2009-03-20T14:42:49.937Z','weight'=>4.0,'cat'=>['electronics','connector'],'spell'=>['Belkin Mobile Power Cord for iPod w/ Dock'],'features'=>['car power adapter, white']},{'id'=>'IW-02','inStock'=>false,'manu'=>'Belkin','name'=>'iPod & iPod Mini USB 2.0 Cable','popularity'=>1,'price'=>11.5,'sku'=>'IW-02','timestamp'=>'2009-03-20T14:42:49.944Z','weight'=>2.0,'cat'=>['electronics','connector'],'spell'=>['iPod & iPod Mini USB 2.0 Cable'],'features'=>['car power adapter for iPod, white']},{'id'=>'MA147LL/A','inStock'=>true,'includes'=>'earbud headphones, USB cable','manu'=>'Apple Computer Inc.','name'=>'Apple 60 GB iPod with Video Playback Black','popularity'=>10,'price'=>399.0,'sku'=>'MA147LL/A','timestamp'=>'2009-03-20T14:42:49.962Z','weight'=>5.5,'cat'=>['electronics','music'],'spell'=>['Apple 60 GB iPod with Video Playback Black'],'features'=>['iTunes, Podcasts, Audiobooks','Stores up to 15,000 songs, 25,000 photos, or 150 hours of video','2.5-inch, 320x240 color TFT LCD display with LED backlight','Up to 20 hours of battery life','Plays AAC, MP3, WAV, AIFF, Audible, Apple Lossless, H.264 video','Notes, Calendar, Phone book, Hold button, Date display, Photo wallet, Built-in games, JPEG photo playback, Upgradeable firmware, USB 2.0 compatibility, Playback speed control, Rechargeable capability, Battery level indication']},{'id'=>'TWINX2048-3200PRO','inStock'=>true,'manu'=>'Corsair Microsystems Inc.','name'=>'CORSAIR XMS 2GB (2 x 1GB) 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) Dual Channel Kit System Memory - Retail','popularity'=>5,'price'=>185.0,'sku'=>'TWINX2048-3200PRO','timestamp'=>'2009-03-20T14:42:49.99Z','cat'=>['electronics','memory'],'spell'=>['CORSAIR XMS 2GB (2 x 1GB) 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) Dual Channel Kit System Memory - Retail'],'features'=>['CAS latency 2, 2-3-3-6 timing, 2.75v, unbuffered, heat-spreader']},{'id'=>'VS1GB400C3','inStock'=>true,'manu'=>'Corsair Microsystems Inc.','name'=>'CORSAIR ValueSelect 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - Retail','popularity'=>7,'price'=>74.99,'sku'=>'VS1GB400C3','timestamp'=>'2009-03-20T14:42:50Z','cat'=>['electronics','memory'],'spell'=>['CORSAIR ValueSelect 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - Retail']},{'id'=>'VDBDB1A16','inStock'=>true,'manu'=>'A-DATA Technology Inc.','name'=>'A-DATA V-Series 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - OEM','popularity'=>5,'sku'=>'VDBDB1A16','timestamp'=>'2009-03-20T14:42:50.004Z','cat'=>['electronics','memory'],'spell'=>['A-DATA V-Series 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - OEM'],'features'=>['CAS latency 3, 2.7v']},{'id'=>'3007WFP','inStock'=>true,'includes'=>'USB cable','manu'=>'Dell, Inc.','name'=>'Dell Widescreen UltraSharp 3007WFP','popularity'=>6,'price'=>2199.0,'sku'=>'3007WFP','timestamp'=>'2009-03-20T14:42:50.017Z','weight'=>401.6,'cat'=>['electronics','monitor'],'spell'=>['Dell Widescreen UltraSharp 3007WFP'],'features'=>['30" TFT active matrix LCD, 2560 x 1600, .25mm dot pitch, 700:1 contrast']},{'id'=>'VA902B','inStock'=>true,'manu'=>'ViewSonic Corp.','name'=>'ViewSonic VA902B - flat panel display - TFT - 19"','popularity'=>6,'price'=>279.95,'sku'=>'VA902B','timestamp'=>'2009-03-20T14:42:50.034Z','weight'=>190.4,'cat'=>['electronics','monitor'],'spell'=>['ViewSonic VA902B - flat panel display - TFT - 19"'],'features'=>['19" TFT active matrix LCD, 8ms response time, 1280 x 1024 native resolution']},{'id'=>'0579B002','inStock'=>true,'manu'=>'Canon Inc.','name'=>'Canon PIXMA MP500 All-In-One Photo Printer','popularity'=>6,'price'=>179.99,'sku'=>'0579B002','timestamp'=>'2009-03-20T14:42:50.062Z','weight'=>352.0,'cat'=>['electronics','multifunction printer','printer','scanner','copier'],'spell'=>['Canon PIXMA MP500 All-In-One Photo Printer'],'features'=>['Multifunction ink-jet color photo printer','Flatbed scanner, optical scan resolution of 1,200 x 2,400 dpi','2.5" color LCD preview screen','Duplex Copying','Printing speed up to 29ppm black, 19ppm color','Hi-Speed USB','memory card: CompactFlash, Micro Drive, SmartMedia, Memory Stick, Memory Stick Pro, SD Card, and MultiMediaCard']}]},'facet_counts'=>{'facet_queries'=>{},'facet_fields'=>{'cat'=>['electronics',14,'memory',3,'card',2,'connector',2,'drive',2,'graphics',2,'hard',2,'monitor',2,'search',2,'software',2],'manu'=>['inc',8,'apach',2,'belkin',2,'canon',2,'comput',2,'corp',2,'corsair',2,'foundat',2,'microsystem',2,'softwar',2]},'facet_dates'=>{}}})
183
187
  end
@@ -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 "Blacklight::User" do
5
4
 
@@ -47,12 +46,12 @@ describe "Blacklight::User" do
47
46
  end
48
47
 
49
48
  it "should know if it doesn't have a search" do
50
- subject.has_searches?.should == false
49
+ expect(subject.has_searches?).to be_false
51
50
  end
52
51
 
53
52
  it "should know if it has a search" do
54
53
  subject.searches << Search.new
55
- subject.has_searches?.should == true
54
+ expect(subject.has_searches?).to be_true
56
55
  end
57
56
 
58
57
  end
@@ -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 Blacklight do
5
4
 
@@ -7,12 +6,12 @@ describe Blacklight do
7
6
 
8
7
  it "should find app/controllers/application_controller.rb" do
9
8
  result = Blacklight.locate_path 'app', 'controllers', 'application_controller.rb'
10
- result.should_not == nil
9
+ expect(result).not_to be_nil
11
10
  end
12
11
 
13
12
  it "should not find blah.rb" do
14
13
  result = Blacklight.locate_path 'blah.rb'
15
- result.should == nil
14
+ expect(result).to be_nil
16
15
  end
17
16
 
18
17
  end
@@ -22,15 +21,15 @@ describe Blacklight do
22
21
  let(:blroot) { File.expand_path(File.join(__FILE__, '..', '..', '..' )) }
23
22
 
24
23
  it 'should return the full path to the BL plugin' do
25
- Blacklight.root.should == blroot
24
+ expect(Blacklight.root).to eq blroot
26
25
  end
27
26
 
28
27
  it 'should return the full path to the model directory' do
29
- Blacklight.models_dir.should == blroot + "/app/models"
28
+ expect(Blacklight.models_dir).to eq blroot + "/app/models"
30
29
  end
31
30
 
32
31
  it 'should return the full path to the controllers directory' do
33
- Blacklight.controllers_dir.should == blroot + "/app/controllers"
32
+ expect(Blacklight.controllers_dir).to eq blroot + "/app/controllers"
34
33
  end
35
34
 
36
35
  end
@@ -1,7 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
3
-
4
- require "rake"
2
+ require 'spec_helper'
3
+ require 'rake'
5
4
 
6
5
  describe "blacklight:delete_old_searches" do
7
6
 
@@ -1,21 +1,20 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
1
+ require 'spec_helper'
3
2
 
4
3
  describe 'Blacklight::Utils' do
5
4
  describe Blacklight::OpenStructWithHashAccess do
6
5
  it "should provide hash-like accessors for OpenStruct data" do
7
6
  a = Blacklight::OpenStructWithHashAccess.new :foo => :bar, :baz => 1
8
7
 
9
- a[:foo].should == :bar
10
- a[:baz].should == 1
11
- a[:asdf].should be_nil
8
+ expect(a[:foo]).to eq :bar
9
+ expect(a[:baz]).to eq 1
10
+ expect(a[:asdf]).to be_nil
12
11
  end
13
12
 
14
13
  it "should provide hash-like writers for OpenStruct data" do
15
14
  a = Blacklight::OpenStructWithHashAccess.new :foo => :bar, :baz => 1
16
15
 
17
16
  a[:asdf] = 'qwerty'
18
- a.asdf.should == 'qwerty'
17
+ expect(a.asdf).to eq 'qwerty'
19
18
 
20
19
  end
21
20
 
@@ -23,12 +22,12 @@ describe 'Blacklight::Utils' do
23
22
  h = Blacklight::OpenStructWithHashAccess.new
24
23
 
25
24
  h["string"] = "value"
26
- h[:string].should == "value"
27
- h.string.should == "value"
25
+ expect(h[:string]).to eq "value"
26
+ expect(h.string).to eq "value"
28
27
 
29
28
  h[:symbol] = "value"
30
- h["symbol"].should == "value"
31
- h.symbol.should == "value"
29
+ expect(h["symbol"]).to eq "value"
30
+ expect(h.symbol).to eq "value"
32
31
  end
33
32
 
34
33
  describe "internal hash table" do
@@ -41,16 +40,16 @@ describe 'Blacklight::Utils' do
41
40
 
42
41
  end
43
42
  it "should expose the internal hash table" do
44
- @h.to_h.should be_a_kind_of(Hash)
45
- @h.to_h[:a].should == 1
43
+ expect(@h.to_h).to be_a_kind_of(Hash)
44
+ expect(@h.to_h[:a]).to eq 1
46
45
  end
47
46
 
48
47
  it "should expose keys" do
49
- @h.keys.should include(:a, :b)
48
+ expect(@h.keys).to include(:a, :b)
50
49
  end
51
50
 
52
51
  it "should expose merge" do
53
- @h.merge(:a => 'a')[:a].should == 'a'
52
+ expect(@h.merge(:a => 'a')[:a]).to eq 'a'
54
53
  end
55
54
 
56
55
  end
@@ -10,15 +10,15 @@ describe Bookmark do
10
10
  @bookmark.id = 1
11
11
  @bookmark.user_id = 1
12
12
  @bookmark.document_id = 'u001'
13
- @bookmark.should be_valid
13
+ expect(@bookmark).to be_valid
14
14
  end
15
15
 
16
16
  it "should require user_id" do
17
- @bookmark.should have(1).error_on(:user_id)
17
+ expect(@bookmark).to have(1).error_on(:user_id)
18
18
  end
19
19
 
20
20
  it "should belong to user" do
21
- Bookmark.reflect_on_association(:user).should_not be_nil
21
+ expect(Bookmark.reflect_on_association(:user)).not_to be_nil
22
22
  end
23
23
 
24
24
  it "should be valid after saving" do
@@ -26,6 +26,6 @@ describe Bookmark do
26
26
  @bookmark.user_id = 1
27
27
  @bookmark.document_id = 'u001'
28
28
  @bookmark.save
29
- @bookmark.should be_valid
29
+ expect(@bookmark).to be_valid
30
30
  end
31
31
  end
@@ -16,26 +16,26 @@ describe RecordMailer do
16
16
  @email = RecordMailer.email_record(@documents,details,{:host =>'projectblacklight.org', :protocol => 'https'})
17
17
  end
18
18
  it "should receive the TO paramater and send the email to that address" do
19
- @email.to.should == ['test@test.com']
19
+ expect(@email.to).to include 'test@test.com'
20
20
  end
21
21
  it "should start the subject w/ Item Record:" do
22
- @email.subject.should =~ /^Item Record:/
22
+ expect(@email.subject).to match /^Item Record:/
23
23
  end
24
24
  it "should put the title of the item in the subject" do
25
- @email.subject.should =~ /The horn/
25
+ expect(@email.subject).to match /The horn/
26
26
  end
27
27
  it "should have the correct from address (w/o the port number)" do
28
- @email.from.should == ["no-reply@projectblacklight.org"]
28
+ expect(@email.from).to include "no-reply@projectblacklight.org"
29
29
  end
30
30
  it "should print out the correct body" do
31
- @email.body.should =~ /Title: The horn/
32
- @email.body.should =~ /Author: Janetzky, Kurt/
33
- @email.body.should =~ /projectblacklight.org/
31
+ expect(@email.body).to match /Title: The horn/
32
+ expect(@email.body).to match /Author: Janetzky, Kurt/
33
+ expect(@email.body).to match /projectblacklight.org/
34
34
  end
35
35
  it "should use https URLs when protocol is set" do
36
36
  details = {:to => 'test@test.com', :message => "This is my message"}
37
37
  @https_email = RecordMailer.email_record(@documents,details,{:host =>'projectblacklight.org', :protocol => 'https'})
38
- @https_email.body.should =~ %r|https://projectblacklight.org/|
38
+ expect(@https_email.body).to match %r|https://projectblacklight.org/|
39
39
  end
40
40
  end
41
41
 
@@ -45,23 +45,23 @@ describe RecordMailer do
45
45
  @sms = RecordMailer.sms_record(@documents,details,{:host =>'projectblacklight.org:3000'})
46
46
  end
47
47
  it "should create the correct TO address for the SMS email" do
48
- @sms.to.should == ['5555555555@txt.att.net']
48
+ expect(@sms.to).to include '5555555555@txt.att.net'
49
49
  end
50
50
  it "should not have a subject" do
51
- @sms.subject.should == "" unless @sms.subject.nil?
51
+ expect(@sms.subject).to be_blank
52
52
  end
53
53
  it "should have the correct from address (w/o the port number)" do
54
- @sms.from.should == ["no-reply@projectblacklight.org"]
54
+ expect(@sms.from).to include "no-reply@projectblacklight.org"
55
55
  end
56
56
  it "should print out the correct body" do
57
- @sms.body.should =~ /The horn/
58
- @sms.body.should =~ /by Janetzky, Kurt/
59
- @sms.body.should =~ /projectblacklight.org:3000/
57
+ expect(@sms.body).to match /The horn/
58
+ expect(@sms.body).to match /by Janetzky, Kurt/
59
+ expect(@sms.body).to match /projectblacklight.org:3000/
60
60
  end
61
61
  it "should use https URL when protocol is set" do
62
62
  details = {:to => '5555555555@txt.att.net'}
63
63
  @https_sms = RecordMailer.sms_record(@documents,details,{:host =>'projectblacklight.org', :protocol => 'https'})
64
- @https_sms.body.should =~ %r|https://projectblacklight.org/|
64
+ expect(@https_sms.body).to match %r|https://projectblacklight.org/|
65
65
  end
66
66
  end
67
67
 
@@ -24,23 +24,23 @@ describe Search do
24
24
  @search.user_id = 1
25
25
  @search.save
26
26
 
27
- @search.saved?.should be_true
27
+ expect(@search).to be_saved
28
28
  end
29
29
  it "should be false when user_id is NULL or less than 1" do
30
30
  @search = Search.create
31
- @search.saved?.should_not be_true
31
+ expect(@search).not_to be_saved
32
32
  end
33
33
  end
34
34
 
35
35
  describe "delete_old_searches" do
36
36
  it "should throw an ArgumentError if days_old is not a number" do
37
- lambda { Search.delete_old_searches("blah") }.should raise_error(ArgumentError)
37
+ expect { Search.delete_old_searches("blah") }.to raise_error(ArgumentError)
38
38
  end
39
39
  it "should throw an ArgumentError if days_old is equal to 0" do
40
- lambda { Search.delete_old_searches(0) }.should raise_error(ArgumentError)
40
+ expect { Search.delete_old_searches(0) }.to raise_error(ArgumentError)
41
41
  end
42
42
  it "should throw an ArgumentError if days_old is less than 0" do
43
- lambda { Search.delete_old_searches(-1) }.should raise_error(ArgumentError)
43
+ expect { Search.delete_old_searches(-1) }.to raise_error(ArgumentError)
44
44
  end
45
45
  it "should destroy searches with no user_id that are older than X days" do
46
46
  Search.destroy_all
@@ -65,9 +65,9 @@ describe Search do
65
65
  saved_search_past.created_at = Date.today - (days_old + 1).days
66
66
  saved_search_past.save
67
67
 
68
- lambda do
68
+ expect do
69
69
  Search.delete_old_searches(days_old)
70
- end.should change(Search, :count).by(-1)
70
+ end.to change(Search, :count).by(-1)
71
71
  end
72
72
 
73
73
  end
@@ -12,22 +12,22 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
12
12
 
13
13
  describe "new" do
14
14
  it "should take a Hash as the argument" do
15
- lambda { SolrDocument.new(:id => 1) }.should_not raise_error
15
+ expect { SolrDocument.new(:id => 1) }.not_to raise_error
16
16
  end
17
17
  end
18
18
 
19
19
  describe "access methods" do
20
20
 
21
21
  it "should have the right value for title_display" do
22
- @solrdoc[:title_display].should_not be_nil
22
+ expect(@solrdoc[:title_display]).not_to be_nil
23
23
  end
24
24
 
25
25
  it "should have the right value for format" do
26
- @solrdoc[:format][0].should == 'Book'
26
+ expect(@solrdoc[:format][0]).to eq 'Book'
27
27
  end
28
28
 
29
29
  it "should provide the item's solr id" do
30
- @solrdoc.id.should == '00282214'
30
+ expect(@solrdoc.id).to eq '00282214'
31
31
  end
32
32
  end
33
33
  end
@@ -4,51 +4,51 @@ describe "Routing" do
4
4
  describe "Paths Generated by Custom Routes:" do
5
5
  # paths generated by custom routes
6
6
  it "should have a path for showing the email form" do
7
- { :get => "/catalog/email" }.should route_to(:controller => 'catalog', :action => 'email')
7
+ expect(:get => "/catalog/email").to route_to(:controller => 'catalog', :action => 'email')
8
8
  end
9
9
  it "should have a path for sending the email" do
10
- { :post => "/catalog/email" }.should route_to(:controller => 'catalog', :action => 'email')
10
+ expect(:post => "/catalog/email").to route_to(:controller => 'catalog', :action => 'email')
11
11
  end
12
12
  it "should map {:controller => 'catalog', :action => 'sms'} to /catalog/sms" do
13
- { :get => "/catalog/sms" }.should route_to(:controller => 'catalog', :action => 'sms')
13
+ expect(:get => "/catalog/sms").to route_to(:controller => 'catalog', :action => 'sms')
14
14
  end
15
15
  it "should map { :controller => 'catalog', :action => 'show', :id => 666 } to /catalog/666" do
16
- { :get => "/catalog/666" }.should route_to(:controller => 'catalog', :action => 'show', :id => "666")
16
+ expect(:get => "/catalog/666").to route_to(:controller => 'catalog', :action => 'show', :id => "666")
17
17
  end
18
18
  it "should map {:controller => 'catalog', :id => '111', :action => 'librarian_view'} to /catalog/111/librarian_view" do
19
- { :get => "/catalog/111/librarian_view" }.should route_to(:controller => 'catalog', :action => 'librarian_view', :id => "111")
20
- { :get => librarian_view_catalog_path('111') }.should route_to(:controller => 'catalog', :action => 'librarian_view', :id => "111")
19
+ expect(:get => "/catalog/111/librarian_view").to route_to(:controller => 'catalog', :action => 'librarian_view', :id => "111")
20
+ expect(:get => librarian_view_catalog_path('111')).to route_to(:controller => 'catalog', :action => 'librarian_view', :id => "111")
21
21
  end
22
22
  end
23
23
 
24
24
 
25
25
  describe "catalog_path for SolrDocument", :test => true do
26
26
  it "should route correctly" do
27
- { :get => catalog_path(SolrDocument.new(:id => 'asdf')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'asdf')
27
+ expect(:get => catalog_path(SolrDocument.new(:id => 'asdf'))).to route_to(:controller => 'catalog', :action => 'show', :id => 'asdf')
28
28
  end
29
29
 
30
30
  context "should escape solr document ids" do
31
31
 
32
32
  it "should pass-through url-valid ids" do
33
- { :get => catalog_path(SolrDocument.new(:id => 'qwerty'))}.should route_to(:controller => 'catalog', :action => 'show', :id => 'qwerty')
33
+ expect(:get => catalog_path(SolrDocument.new(:id => 'qwerty'))).to route_to(:controller => 'catalog', :action => 'show', :id => 'qwerty')
34
34
  end
35
35
 
36
36
  it "should route url-like ids" do
37
37
  pending "This works if you configure your routing to have very liberal constraints on :id.. not sure how to go about testing it though"
38
- { :get => catalog_path(SolrDocument.new(:id => 'http://example.com'))}.should route_to(:controller => 'catalog', :action => 'show', :id => 'http://example.com')
38
+ expect(:get => catalog_path(SolrDocument.new(:id => 'http://example.com'))).to route_to(:controller => 'catalog', :action => 'show', :id => 'http://example.com')
39
39
  end
40
40
 
41
41
  it "should route ids with whitespace" do
42
- { :get => catalog_path(SolrDocument.new(:id => 'mm 123')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'mm 123')
42
+ expect(:get => catalog_path(SolrDocument.new(:id => 'mm 123'))).to route_to(:controller => 'catalog', :action => 'show', :id => 'mm 123')
43
43
  end
44
44
 
45
45
  it "should route ids with a literal '+'" do
46
- { :get => catalog_path(SolrDocument.new(:id => 'this+that')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'this+that')
46
+ expect(:get => catalog_path(SolrDocument.new(:id => 'this+that'))).to route_to(:controller => 'catalog', :action => 'show', :id => 'this+that')
47
47
  end
48
48
 
49
49
  it "should route ids with a literal '/" do
50
50
  pending "This works if you configure your routing to have very liberal constraints on :id.. not sure how to go about testing it though"
51
- { :get => catalog_path(SolrDocument.new(:id => 'and/or')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'and/or')
51
+ expect(:get => catalog_path(SolrDocument.new(:id => 'and/or'))).to route_to(:controller => 'catalog', :action => 'show', :id => 'and/or')
52
52
  end
53
53
  end
54
54
  end
data/spec/spec_helper.rb CHANGED
@@ -6,11 +6,9 @@
6
6
  ENV["RAILS_ENV"] ||= 'test'
7
7
 
8
8
  ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
9
- if ENV['COVERAGE'] and RUBY_VERSION =~ /^1.9/ and ruby_engine != "jruby"
9
+ if ENV['COVERAGE'] and ruby_engine != "jruby"
10
10
  require 'simplecov'
11
- require 'simplecov-rcov'
12
11
 
13
- SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
14
12
  SimpleCov.start do
15
13
  root File.expand_path(File.dirname(__FILE__) + "../../..")
16
14
  end