sunspot 2.2.7 → 2.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +2 -0
  4. data/Appraisals +7 -0
  5. data/Gemfile +0 -8
  6. data/gemfiles/.gitkeep +0 -0
  7. data/lib/sunspot/dsl/scope.rb +6 -1
  8. data/lib/sunspot/field.rb +11 -0
  9. data/lib/sunspot/field_factory.rb +6 -2
  10. data/lib/sunspot/query/bbox.rb +5 -1
  11. data/lib/sunspot/query/restriction.rb +11 -0
  12. data/lib/sunspot/search/hit_enumerable.rb +4 -1
  13. data/lib/sunspot/search/standard_search.rb +2 -3
  14. data/lib/sunspot/version.rb +1 -1
  15. data/spec/api/adapters_spec.rb +19 -19
  16. data/spec/api/batcher_spec.rb +15 -15
  17. data/spec/api/binding_spec.rb +3 -3
  18. data/spec/api/class_set_spec.rb +3 -3
  19. data/spec/api/hit_enumerable_spec.rb +32 -9
  20. data/spec/api/indexer/attributes_spec.rb +31 -31
  21. data/spec/api/indexer/batch_spec.rb +8 -7
  22. data/spec/api/indexer/dynamic_fields_spec.rb +8 -8
  23. data/spec/api/indexer/fixed_fields_spec.rb +12 -12
  24. data/spec/api/indexer/fulltext_spec.rb +8 -8
  25. data/spec/api/indexer/removal_spec.rb +14 -14
  26. data/spec/api/indexer_spec.rb +2 -2
  27. data/spec/api/query/advanced_manipulation_examples.rb +3 -3
  28. data/spec/api/query/connectives_examples.rb +26 -14
  29. data/spec/api/query/dsl_spec.rb +17 -9
  30. data/spec/api/query/dynamic_fields_examples.rb +18 -18
  31. data/spec/api/query/faceting_examples.rb +62 -62
  32. data/spec/api/query/fulltext_examples.rb +56 -55
  33. data/spec/api/query/function_spec.rb +26 -26
  34. data/spec/api/query/geo_examples.rb +6 -6
  35. data/spec/api/query/group_spec.rb +6 -6
  36. data/spec/api/query/highlighting_examples.rb +26 -26
  37. data/spec/api/query/join_spec.rb +2 -2
  38. data/spec/api/query/more_like_this_spec.rb +29 -29
  39. data/spec/api/query/ordering_pagination_examples.rb +25 -25
  40. data/spec/api/query/scope_examples.rb +39 -39
  41. data/spec/api/query/spatial_examples.rb +3 -3
  42. data/spec/api/query/spellcheck_examples.rb +3 -3
  43. data/spec/api/query/standard_spec.rb +1 -1
  44. data/spec/api/query/stats_examples.rb +8 -8
  45. data/spec/api/query/text_field_scoping_examples.rb +5 -5
  46. data/spec/api/query/types_spec.rb +4 -4
  47. data/spec/api/search/cursor_paginated_collection_spec.rb +12 -12
  48. data/spec/api/search/dynamic_fields_spec.rb +4 -4
  49. data/spec/api/search/faceting_spec.rb +55 -52
  50. data/spec/api/search/highlighting_spec.rb +7 -7
  51. data/spec/api/search/hits_spec.rb +29 -29
  52. data/spec/api/search/paginated_collection_spec.rb +18 -18
  53. data/spec/api/search/results_spec.rb +13 -13
  54. data/spec/api/search/search_spec.rb +3 -3
  55. data/spec/api/search/stats_spec.rb +10 -10
  56. data/spec/api/session_proxy/class_sharding_session_proxy_spec.rb +19 -18
  57. data/spec/api/session_proxy/id_sharding_session_proxy_spec.rb +9 -9
  58. data/spec/api/session_proxy/master_slave_session_proxy_spec.rb +10 -6
  59. data/spec/api/session_proxy/retry_5xx_session_proxy_spec.rb +10 -10
  60. data/spec/api/session_proxy/sharding_session_proxy_spec.rb +14 -13
  61. data/spec/api/session_proxy/silent_fail_session_proxy_spec.rb +2 -2
  62. data/spec/api/session_proxy/spec_helper.rb +1 -1
  63. data/spec/api/session_proxy/thread_local_session_proxy_spec.rb +9 -5
  64. data/spec/api/session_spec.rb +42 -42
  65. data/spec/api/sunspot_spec.rb +4 -4
  66. data/spec/integration/atomic_updates_spec.rb +25 -11
  67. data/spec/integration/dynamic_fields_spec.rb +10 -10
  68. data/spec/integration/faceting_spec.rb +39 -39
  69. data/spec/integration/field_grouping_spec.rb +16 -16
  70. data/spec/integration/field_lists_spec.rb +41 -0
  71. data/spec/integration/geospatial_spec.rb +19 -8
  72. data/spec/integration/highlighting_spec.rb +5 -5
  73. data/spec/integration/indexing_spec.rb +5 -5
  74. data/spec/integration/keyword_search_spec.rb +47 -45
  75. data/spec/integration/local_search_spec.rb +4 -4
  76. data/spec/integration/more_like_this_spec.rb +7 -7
  77. data/spec/integration/scoped_search_spec.rb +107 -107
  78. data/spec/integration/spellcheck_spec.rb +52 -7
  79. data/spec/integration/stats_spec.rb +10 -10
  80. data/spec/integration/stored_fields_spec.rb +1 -1
  81. data/spec/integration/test_pagination.rb +4 -4
  82. data/spec/integration/unicode_spec.rb +1 -1
  83. data/spec/mocks/post.rb +5 -1
  84. data/spec/spec_helper.rb +11 -6
  85. data/sunspot.gemspec +3 -1
  86. metadata +40 -7
@@ -4,151 +4,151 @@ require 'bigdecimal'
4
4
  describe 'indexing attribute fields', :type => :indexer do
5
5
  it 'should correctly index a stored string attribute field' do
6
6
  session.index(post(:title => 'A Title'))
7
- connection.should have_add_with(:title_ss => 'A Title')
7
+ expect(connection).to have_add_with(:title_ss => 'A Title')
8
8
  end
9
9
 
10
10
  it 'should correctly index an integer attribute field' do
11
11
  session.index(post(:blog_id => 4))
12
- connection.should have_add_with(:blog_id_i => '4')
12
+ expect(connection).to have_add_with(:blog_id_i => '4')
13
13
  end
14
14
 
15
15
  it 'should correctly index a long attribute field' do
16
16
  session.index(Namespaced::Comment.new(:hash => 2**30))
17
- connection.should have_add_with(:hash_l => '1073741824')
17
+ expect(connection).to have_add_with(:hash_l => '1073741824')
18
18
  end
19
19
 
20
20
  it 'should correctly index a float attribute field' do
21
21
  session.index(post(:ratings_average => 2.23))
22
- connection.should have_add_with(:average_rating_ft => '2.23')
22
+ expect(connection).to have_add_with(:average_rating_ft => '2.23')
23
23
  end
24
24
 
25
25
  it 'should correctly index a double attribute field' do
26
26
  session.index(Namespaced::Comment.new(:average_rating => 2.23))
27
- connection.should have_add_with(:average_rating_e => '2.23')
27
+ expect(connection).to have_add_with(:average_rating_e => '2.23')
28
28
  end
29
29
 
30
30
  it 'should correctly index a trie integer attribute field' do
31
31
  session.index(Photo.new(:size => 104856))
32
- connection.should have_add_with(:size_it => '104856')
32
+ expect(connection).to have_add_with(:size_it => '104856')
33
33
  end
34
34
 
35
35
  it 'should correctly index a trie float attribute field' do
36
36
  session.index(Photo.new(:average_rating => 2.23))
37
- connection.should have_add_with(:average_rating_ft => '2.23')
37
+ expect(connection).to have_add_with(:average_rating_ft => '2.23')
38
38
  end
39
39
 
40
40
  it 'should correctly index a trie time attribute field' do
41
41
  session.index(Photo.new(:created_at => Time.parse('2009-12-16 15:00:00 -0400')))
42
- connection.should have_add_with(:created_at_dt => '2009-12-16T19:00:00Z')
42
+ expect(connection).to have_add_with(:created_at_dt => '2009-12-16T19:00:00Z')
43
43
  end
44
44
 
45
45
  it 'should allow indexing by a multiple-value field' do
46
46
  session.index(post(:category_ids => [3, 14]))
47
- connection.should have_add_with(:category_ids_im => ['3', '14'])
47
+ expect(connection).to have_add_with(:category_ids_im => ['3', '14'])
48
48
  end
49
49
 
50
50
  it 'should not index a single-value field with newlines as multiple' do
51
51
  session.index(post(:title => "Multi\nLine"))
52
- connection.adds.last.first.field_by_name(:title_ss).value.should == "Multi\nLine"
52
+ expect(connection.adds.last.first.field_by_name(:title_ss).value).to eq("Multi\nLine")
53
53
  end
54
54
 
55
55
  it 'should correctly index a time field' do
56
56
  session.index(
57
57
  post(:published_at => Time.parse('1983-07-08 05:00:00 -0400'))
58
58
  )
59
- connection.should have_add_with(:published_at_dt => '1983-07-08T09:00:00Z')
59
+ expect(connection).to have_add_with(:published_at_dt => '1983-07-08T09:00:00Z')
60
60
  end
61
61
 
62
62
  it 'should correctly index a time field that\'s after 32-bit Y2K' do
63
63
  session.index(
64
64
  post(:published_at => DateTime.parse('2050-07-08 05:00:00 -0400'))
65
65
  )
66
- connection.should have_add_with(:published_at_dt => '2050-07-08T09:00:00Z')
66
+ expect(connection).to have_add_with(:published_at_dt => '2050-07-08T09:00:00Z')
67
67
  end
68
68
 
69
69
  it 'should correctly index a date field' do
70
70
  session.index(post(:expire_date => Date.new(2009, 07, 13)))
71
- connection.should have_add_with(:expire_date_d => '2009-07-13T00:00:00Z')
71
+ expect(connection).to have_add_with(:expire_date_d => '2009-07-13T00:00:00Z')
72
72
  end
73
73
 
74
74
  it 'should correctly index a date range field' do
75
75
  session.index(post(:featured_for => Date.new(2009, 07, 13)..Date.new(2009, 12, 25)))
76
- connection.should have_add_with(:featured_for_dr => '[2009-07-13T00:00:00Z TO 2009-12-25T00:00:00Z]')
76
+ expect(connection).to have_add_with(:featured_for_dr => '[2009-07-13T00:00:00Z TO 2009-12-25T00:00:00Z]')
77
77
  end
78
78
 
79
79
  it 'should correctly index a boolean field' do
80
80
  session.index(post(:featured => true))
81
- connection.should have_add_with(:featured_bs => 'true')
81
+ expect(connection).to have_add_with(:featured_bs => 'true')
82
82
  end
83
83
 
84
84
  it 'should correctly index a false boolean field' do
85
85
  session.index(post(:featured => false))
86
- connection.should have_add_with(:featured_bs => 'false')
86
+ expect(connection).to have_add_with(:featured_bs => 'false')
87
87
  end
88
88
 
89
89
  it 'should not index a nil boolean field' do
90
90
  session.index(post)
91
- connection.should_not have_add_with(:featured_bs)
91
+ expect(connection).not_to have_add_with(:featured_bs)
92
92
  end
93
93
 
94
94
  it 'should index latitude and longitude as a pair' do
95
95
  session.index(post(:coordinates => Sunspot::Util::Coordinates.new(40.7, -73.5)))
96
- connection.should have_add_with(:coordinates_s => 'dr5xx3nytvgs')
96
+ expect(connection).to have_add_with(:coordinates_s => 'dr5xx3nytvgs')
97
97
  end
98
98
 
99
99
  it 'should index latitude and longitude passed as non-Floats' do
100
100
  coordinates = Sunspot::Util::Coordinates.new(
101
101
  BigDecimal.new('40.7'), BigDecimal.new('-73.5'))
102
102
  session.index(post(:coordinates => coordinates))
103
- connection.should have_add_with(:coordinates_s => 'dr5xx3nytvgs')
103
+ expect(connection).to have_add_with(:coordinates_s => 'dr5xx3nytvgs')
104
104
  end
105
105
 
106
106
  it 'should correctly index an attribute field with block access' do
107
107
  session.index(post(:title => 'The Blog Post'))
108
- connection.should have_add_with(:sort_title_s => 'blog post')
108
+ expect(connection).to have_add_with(:sort_title_s => 'blog post')
109
109
  end
110
110
 
111
111
  it 'should correctly index an attribute field with instance-external block access' do
112
112
  session.index(post(:category_ids => [1, 2, 3]))
113
- connection.should have_add_with(:primary_category_id_i => '1')
113
+ expect(connection).to have_add_with(:primary_category_id_i => '1')
114
114
  end
115
115
 
116
116
  it 'should correctly index a field that is defined on a superclass' do
117
117
  Sunspot.setup(SuperClass) { string :author_name }
118
118
  session.index(post(:author_name => 'Mat Brown'))
119
- connection.should have_add_with(:author_name_s => 'Mat Brown')
119
+ expect(connection).to have_add_with(:author_name_s => 'Mat Brown')
120
120
  end
121
121
 
122
122
  it 'should throw a NoMethodError only if a nonexistent type is defined' do
123
- lambda { Sunspot.setup(Post) { string :author_name }}.should_not raise_error
124
- lambda { Sunspot.setup(Post) { bogus :journey }}.should raise_error(NoMethodError)
123
+ expect { Sunspot.setup(Post) { string :author_name }}.not_to raise_error
124
+ expect { Sunspot.setup(Post) { bogus :journey }}.to raise_error(NoMethodError)
125
125
  end
126
126
 
127
127
  it 'should throw a NoMethodError if a nonexistent field argument is passed' do
128
- lambda { Sunspot.setup(Post) { string :author_name, :bogus => :argument }}.should raise_error(ArgumentError)
128
+ expect { Sunspot.setup(Post) { string :author_name, :bogus => :argument }}.to raise_error(ArgumentError)
129
129
  end
130
130
 
131
131
  it 'should throw an ArgumentError if single-value field tries to index multiple values' do
132
- lambda do
132
+ expect do
133
133
  Sunspot.setup(Post) { string :author_name }
134
134
  session.index(post(:author_name => ['Mat Brown', 'Matthew Brown']))
135
- end.should raise_error(ArgumentError)
135
+ end.to raise_error(ArgumentError)
136
136
  end
137
137
 
138
138
  it 'should throw an ArgumentError if specifying more_like_this on type that does not support it' do
139
- lambda do
139
+ expect do
140
140
  Sunspot.setup(Post) { integer :popularity, :more_like_this => true }
141
- end.should raise_error(ArgumentError)
141
+ end.to raise_error(ArgumentError)
142
142
  end
143
143
 
144
144
  it 'should use a specified field name when the :as option is set' do
145
145
  session.index(post(:title => 'A Title'))
146
- connection.should have_add_with(:legacy_field_s => 'legacy A Title')
146
+ expect(connection).to have_add_with(:legacy_field_s => 'legacy A Title')
147
147
  end
148
148
 
149
149
  it 'should use a specified field name when the :as option is set for array values' do
150
150
  session.index(post(:title => 'Another Title'))
151
- connection.should have_add_with(:legacy_array_field_sm => ['first string', 'second string'])
151
+ expect(connection).to have_add_with(:legacy_array_field_sm => ['first string', 'second string'])
152
152
  end
153
153
  end
154
154
 
@@ -9,7 +9,7 @@ describe 'batch indexing', :type => :indexer do
9
9
  session.index(post)
10
10
  end
11
11
  end
12
- connection.adds.length.should == 1
12
+ expect(connection.adds.length).to eq(1)
13
13
  end
14
14
 
15
15
  it 'should add all batched adds' do
@@ -19,8 +19,9 @@ describe 'batch indexing', :type => :indexer do
19
19
  end
20
20
  end
21
21
  add = connection.adds.last
22
- connection.adds.first.map { |add| add.field_by_name(:id).value }.should ==
22
+ expect(connection.adds.first.map { |add| add.field_by_name(:id).value }).to eq(
23
23
  posts.map { |post| "Post #{post.id}" }
24
+ )
24
25
  end
25
26
 
26
27
  it 'should not index changes to models that happen after index call' do
@@ -29,13 +30,13 @@ describe 'batch indexing', :type => :indexer do
29
30
  session.index(post)
30
31
  post.title = 'Title'
31
32
  end
32
- connection.adds.first.first.field_by_name(:title_ss).should be_nil
33
+ expect(connection.adds.first.first.field_by_name(:title_ss)).to be_nil
33
34
  end
34
35
 
35
36
  it 'should batch an add and a delete' do
36
- pending 'batching all operations'
37
- connection.should_not_receive(:add)
38
- connection.should_not_receive(:remove)
37
+ skip 'batching all operations'
38
+ expect(connection).not_to receive(:add)
39
+ expect(connection).not_to receive(:remove)
39
40
  session.batch do
40
41
  session.index(posts[0])
41
42
  session.remove(posts[1])
@@ -64,7 +65,7 @@ describe 'batch indexing', :type => :indexer do
64
65
  a_nested_batch
65
66
  nested_batches_adds = connection.adds
66
67
 
67
- nested_batches_adds.first.first.field_by_name(:title_ss).value.should eq(
68
+ expect(nested_batches_adds.first.first.field_by_name(:title_ss).value).to eq(
68
69
  two_sets_of_batches_adds.first.first.field_by_name(:title_ss).value
69
70
  )
70
71
  end
@@ -3,40 +3,40 @@ require File.expand_path('spec_helper', File.dirname(__FILE__))
3
3
  describe 'indexing dynamic fields' do
4
4
  it 'indexes string data' do
5
5
  session.index(post(:custom_string => { :test => 'string' }))
6
- connection.should have_add_with(:"custom_string:test_ss" => 'string')
6
+ expect(connection).to have_add_with(:"custom_string:test_ss" => 'string')
7
7
  end
8
8
 
9
9
  it 'indexes integer data with virtual accessor' do
10
10
  session.index(post(:category_ids => [1, 2]))
11
- connection.should have_add_with(:"custom_integer:1_i" => '1', :"custom_integer:2_i" => '1')
11
+ expect(connection).to have_add_with(:"custom_integer:1_i" => '1', :"custom_integer:2_i" => '1')
12
12
  end
13
13
 
14
14
  it 'indexes float data' do
15
15
  session.index(post(:custom_fl => { :test => 1.5 }))
16
- connection.should have_add_with(:"custom_float:test_fm" => '1.5')
16
+ expect(connection).to have_add_with(:"custom_float:test_fm" => '1.5')
17
17
  end
18
18
 
19
19
  it 'indexes time data' do
20
20
  session.index(post(:custom_time => { :test => Time.parse('2009-05-18 18:05:00 -0400') }))
21
- connection.should have_add_with(:"custom_time:test_d" => '2009-05-18T22:05:00Z')
21
+ expect(connection).to have_add_with(:"custom_time:test_d" => '2009-05-18T22:05:00Z')
22
22
  end
23
23
 
24
24
  it 'indexes boolean data' do
25
25
  session.index(post(:custom_boolean => { :test => false }))
26
- connection.should have_add_with(:"custom_boolean:test_b" => 'false')
26
+ expect(connection).to have_add_with(:"custom_boolean:test_b" => 'false')
27
27
  end
28
28
 
29
29
  it 'indexes multiple values for a field' do
30
30
  session.index(post(:custom_fl => { :test => [1.0, 2.1, 3.2] }))
31
- connection.should have_add_with(:"custom_float:test_fm" => %w(1.0 2.1 3.2))
31
+ expect(connection).to have_add_with(:"custom_float:test_fm" => %w(1.0 2.1 3.2))
32
32
  end
33
33
 
34
34
  it 'should throw a NoMethodError if dynamic text field defined' do
35
- lambda do
35
+ expect do
36
36
  Sunspot.setup(Post) do
37
37
  dynamic_text :custom_text
38
38
  end
39
- end.should raise_error(NoMethodError)
39
+ end.to raise_error(NoMethodError)
40
40
  end
41
41
  end
42
42
 
@@ -3,28 +3,28 @@ require File.expand_path('spec_helper', File.dirname(__FILE__))
3
3
  describe 'indexing fixed fields', :type => :indexer do
4
4
  it 'should index id' do
5
5
  session.index post
6
- connection.should have_add_with(:id => "Post #{post.id}")
6
+ expect(connection).to have_add_with(:id => "Post #{post.id}")
7
7
  end
8
8
 
9
9
  it 'should index type' do
10
10
  session.index post
11
- connection.should have_add_with(:type => ['Post', 'SuperClass', 'MockRecord'])
11
+ expect(connection).to have_add_with(:type => ['Post', 'SuperClass', 'MockRecord'])
12
12
  end
13
13
 
14
14
  it 'should not index join fields' do
15
15
  session.index PhotoContainer.new
16
- connection.should_not have_add_with(:photo_caption => 'blah')
16
+ expect(connection).not_to have_add_with(:photo_caption => 'blah')
17
17
  end
18
18
 
19
19
  it 'should index class name' do
20
20
  session.index post
21
- connection.should have_add_with(:class_name => 'Post')
21
+ expect(connection).to have_add_with(:class_name => 'Post')
22
22
  end
23
23
 
24
24
  it 'should index the array of objects supplied' do
25
25
  posts = Array.new(2) { Post.new }
26
26
  session.index posts
27
- connection.should have_add_with(
27
+ expect(connection).to have_add_with(
28
28
  { :id => "Post #{posts.first.id}" },
29
29
  { :id => "Post #{posts.last.id}" }
30
30
  )
@@ -33,7 +33,7 @@ describe 'indexing fixed fields', :type => :indexer do
33
33
  it 'should index an array containing more than one type of object' do
34
34
  post1, comment, post2 = objects = [Post.new, Namespaced::Comment.new, Post.new]
35
35
  session.index objects
36
- connection.should have_add_with(
36
+ expect(connection).to have_add_with(
37
37
  { :id => "Post #{post1.id}", :type => ['Post', 'SuperClass', 'MockRecord'] },
38
38
  { :id => "Namespaced::Comment #{comment.id}", :type => ['Namespaced::Comment', 'MockRecord'] },
39
39
  { :id => "Post #{post2.id}", :type => ['Post', 'SuperClass', 'MockRecord'] }
@@ -41,22 +41,22 @@ describe 'indexing fixed fields', :type => :indexer do
41
41
  end
42
42
 
43
43
  it 'commits immediately after index! called' do
44
- connection.should_receive(:add).ordered
45
- connection.should_receive(:commit).ordered
44
+ expect(connection).to receive(:add).ordered
45
+ expect(connection).to receive(:commit).ordered
46
46
  session.index!(post)
47
47
  end
48
48
 
49
49
  it 'raises an ArgumentError if an attempt is made to index an object that has no configuration' do
50
- lambda { session.index(Blog.new) }.should raise_error(Sunspot::NoSetupError)
50
+ expect { session.index(Blog.new) }.to raise_error(Sunspot::NoSetupError)
51
51
  end
52
52
 
53
53
  it 'raises a NoAdapterError if class without adapter is indexed' do
54
- lambda { session.index(User.new) }.should raise_error(Sunspot::NoAdapterError)
54
+ expect { session.index(User.new) }.to raise_error(Sunspot::NoAdapterError)
55
55
  end
56
56
 
57
57
  it 'raises an ArgumentError if a non-word character is included in the field name' do
58
- lambda do
58
+ expect do
59
59
  Sunspot.setup(Post) { string :"bad name" }
60
- end.should raise_error(ArgumentError)
60
+ end.to raise_error(ArgumentError)
61
61
  end
62
62
  end
@@ -3,41 +3,41 @@ require File.expand_path('spec_helper', File.dirname(__FILE__))
3
3
  describe 'indexing fulltext fields' do
4
4
  it 'indexes text field' do
5
5
  session.index(post(:title => 'A Title'))
6
- connection.should have_add_with(:title_text => 'A Title')
6
+ expect(connection).to have_add_with(:title_text => 'A Title')
7
7
  end
8
8
 
9
9
  it 'indexes stored text field' do
10
10
  session.index(post(:body => 'Test body'))
11
- connection.should have_add_with(:body_textsv => 'Test body')
11
+ expect(connection).to have_add_with(:body_textsv => 'Test body')
12
12
  end
13
13
 
14
14
  it 'indexes text field with boost' do
15
15
  session.index(post(:title => 'A Title'))
16
- connection.adds.last.first.field_by_name(:title_text).attrs[:boost].should == 2
16
+ expect(connection.adds.last.first.field_by_name(:title_text).attrs[:boost]).to eq(2)
17
17
  end
18
18
 
19
19
  it 'indexes multiple values for a text field' do
20
20
  session.index(post(:body => %w(some title)))
21
- connection.should have_add_with(:body_textsv => %w(some title))
21
+ expect(connection).to have_add_with(:body_textsv => %w(some title))
22
22
  end
23
23
 
24
24
  it 'indexes text via a block accessor' do
25
25
  session.index(post(:title => 'backwards'))
26
- connection.should have_add_with(:backwards_title_text => 'sdrawkcab')
26
+ expect(connection).to have_add_with(:backwards_title_text => 'sdrawkcab')
27
27
  end
28
28
 
29
29
  it 'indexes document level boost using block' do
30
30
  session.index(post(:ratings_average => 4.0))
31
- connection.adds.last.first.attrs[:boost].should == 1.25
31
+ expect(connection.adds.last.first.attrs[:boost]).to eq(1.25)
32
32
  end
33
33
 
34
34
  it 'indexes document level boost using attribute' do
35
35
  session.index(Namespaced::Comment.new(:boost => 1.5))
36
- connection.adds.last.first.attrs[:boost].should == 1.5
36
+ expect(connection.adds.last.first.attrs[:boost]).to eq(1.5)
37
37
  end
38
38
 
39
39
  it 'indexes document level boost defined statically' do
40
40
  session.index(Photo.new)
41
- connection.adds.last.first.attrs[:boost].should == 0.75
41
+ expect(connection.adds.last.first.attrs[:boost]).to eq(0.75)
42
42
  end
43
43
  end
@@ -3,54 +3,54 @@ require File.expand_path('spec_helper', File.dirname(__FILE__))
3
3
  describe 'document removal', :type => :indexer do
4
4
  it 'removes an object from the index' do
5
5
  session.remove(post)
6
- connection.should have_delete("Post #{post.id}")
6
+ expect(connection).to have_delete("Post #{post.id}")
7
7
  end
8
8
 
9
9
  it 'removes an object by type and id' do
10
10
  session.remove_by_id(Post, 1)
11
- connection.should have_delete('Post 1')
11
+ expect(connection).to have_delete('Post 1')
12
12
  end
13
13
 
14
14
  it 'removes an object by type and ids' do
15
15
  session.remove_by_id(Post, 1, 2)
16
- connection.should have_delete('Post 1', 'Post 2')
16
+ expect(connection).to have_delete('Post 1', 'Post 2')
17
17
  end
18
18
 
19
19
  it 'removes an object by type and ids array' do
20
20
  session.remove_by_id(Post, [1, 2])
21
- connection.should have_delete('Post 1', 'Post 2')
21
+ expect(connection).to have_delete('Post 1', 'Post 2')
22
22
  end
23
23
 
24
24
  it 'removes an object by type and ids and immediately commits' do
25
- connection.should_receive(:delete_by_id).with(['Post 1', 'Post 2', 'Post 3']).ordered
26
- connection.should_receive(:commit).ordered
25
+ expect(connection).to receive(:delete_by_id).with(['Post 1', 'Post 2', 'Post 3']).ordered
26
+ expect(connection).to receive(:commit).ordered
27
27
  session.remove_by_id!(Post, 1, 2, 3)
28
28
  end
29
29
 
30
30
  it 'removes an object from the index and immediately commits' do
31
- connection.should_receive(:delete_by_id).ordered
32
- connection.should_receive(:commit).ordered
31
+ expect(connection).to receive(:delete_by_id).ordered
32
+ expect(connection).to receive(:commit).ordered
33
33
  session.remove!(post)
34
34
  end
35
35
 
36
36
  it 'removes everything from the index' do
37
37
  session.remove_all
38
- connection.should have_delete_by_query("*:*")
38
+ expect(connection).to have_delete_by_query("*:*")
39
39
  end
40
40
 
41
41
  it 'removes everything from the index and immediately commits' do
42
- connection.should_receive(:delete_by_query).ordered
43
- connection.should_receive(:commit).ordered
42
+ expect(connection).to receive(:delete_by_query).ordered
43
+ expect(connection).to receive(:commit).ordered
44
44
  session.remove_all!
45
45
  end
46
46
 
47
47
  it 'removes everything of a given class from the index' do
48
48
  session.remove_all(Post)
49
- connection.should have_delete_by_query("type:Post")
49
+ expect(connection).to have_delete_by_query("type:Post")
50
50
  end
51
51
 
52
52
  it 'correctly escapes namespaced classes when removing everything from the index' do
53
- connection.should_receive(:delete_by_query).with('type:Namespaced\:\:Comment')
53
+ expect(connection).to receive(:delete_by_query).with('type:Namespaced\:\:Comment')
54
54
  session.remove_all(Namespaced::Comment)
55
55
  end
56
56
 
@@ -58,6 +58,6 @@ describe 'document removal', :type => :indexer do
58
58
  session.remove(Post) do
59
59
  with(:title, 'monkeys')
60
60
  end
61
- connection.should have_delete_by_query("(type:Post AND title_ss:monkeys)")
61
+ expect(connection).to have_delete_by_query("(type:Post AND title_ss:monkeys)")
62
62
  end
63
63
  end