thinking-sphinx 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -2
  3. data/Appraisals +13 -0
  4. data/Gemfile +2 -1
  5. data/HISTORY +19 -0
  6. data/README.textile +3 -2
  7. data/gemfiles/rails_3_2.gemfile +2 -1
  8. data/gemfiles/rails_4_0.gemfile +2 -1
  9. data/gemfiles/rails_4_1.gemfile +2 -1
  10. data/gemfiles/rails_4_2.gemfile +2 -1
  11. data/gemfiles/rails_5_0.gemfile +12 -0
  12. data/lib/thinking_sphinx.rb +2 -0
  13. data/lib/thinking_sphinx/active_record/attribute/type.rb +17 -3
  14. data/lib/thinking_sphinx/active_record/callbacks/delta_callbacks.rb +12 -4
  15. data/lib/thinking_sphinx/active_record/database_adapters.rb +1 -1
  16. data/lib/thinking_sphinx/active_record/sql_builder/query.rb +4 -0
  17. data/lib/thinking_sphinx/active_record/sql_source.rb +1 -1
  18. data/lib/thinking_sphinx/configuration.rb +3 -2
  19. data/lib/thinking_sphinx/connection.rb +23 -10
  20. data/lib/thinking_sphinx/deltas/index_job.rb +6 -2
  21. data/lib/thinking_sphinx/errors.rb +25 -0
  22. data/lib/thinking_sphinx/middlewares/active_record_translator.rb +14 -2
  23. data/lib/thinking_sphinx/railtie.rb +1 -1
  24. data/lib/thinking_sphinx/rake_interface.rb +71 -23
  25. data/lib/thinking_sphinx/real_time/callbacks/real_time_callbacks.rb +15 -7
  26. data/lib/thinking_sphinx/real_time/populator.rb +3 -3
  27. data/lib/thinking_sphinx/tasks.rb +7 -8
  28. data/lib/thinking_sphinx/wildcard.rb +1 -1
  29. data/spec/acceptance/association_scoping_spec.rb +5 -5
  30. data/spec/acceptance/attribute_access_spec.rb +4 -4
  31. data/spec/acceptance/attribute_updates_spec.rb +3 -3
  32. data/spec/acceptance/batch_searching_spec.rb +4 -4
  33. data/spec/acceptance/big_integers_spec.rb +6 -6
  34. data/spec/acceptance/connection_spec.rb +23 -0
  35. data/spec/acceptance/excerpts_spec.rb +8 -8
  36. data/spec/acceptance/facets_spec.rb +13 -13
  37. data/spec/acceptance/geosearching_spec.rb +8 -8
  38. data/spec/acceptance/grouping_by_attributes_spec.rb +10 -10
  39. data/spec/acceptance/index_options_spec.rb +16 -16
  40. data/spec/acceptance/indexing_spec.rb +3 -3
  41. data/spec/acceptance/paginating_search_results_spec.rb +3 -3
  42. data/spec/acceptance/real_time_updates_spec.rb +4 -4
  43. data/spec/acceptance/remove_deleted_records_spec.rb +12 -12
  44. data/spec/acceptance/search_counts_spec.rb +2 -2
  45. data/spec/acceptance/search_for_just_ids_spec.rb +2 -2
  46. data/spec/acceptance/searching_across_models_spec.rb +6 -6
  47. data/spec/acceptance/searching_across_schemas_spec.rb +10 -10
  48. data/spec/acceptance/searching_on_fields_spec.rb +9 -9
  49. data/spec/acceptance/searching_with_filters_spec.rb +16 -16
  50. data/spec/acceptance/searching_with_sti_spec.rb +9 -9
  51. data/spec/acceptance/searching_within_a_model_spec.rb +17 -17
  52. data/spec/acceptance/sorting_search_results_spec.rb +6 -6
  53. data/spec/acceptance/specifying_sql_spec.rb +62 -62
  54. data/spec/acceptance/sphinx_scopes_spec.rb +9 -9
  55. data/spec/acceptance/sql_deltas_spec.rb +7 -7
  56. data/spec/acceptance/support/database_cleaner.rb +1 -1
  57. data/spec/acceptance/support/sphinx_controller.rb +4 -1
  58. data/spec/acceptance/support/sphinx_helpers.rb +4 -0
  59. data/spec/acceptance/suspended_deltas_spec.rb +9 -9
  60. data/spec/internal/app/indices/article_index.rb +2 -2
  61. data/spec/internal/app/indices/book_index.rb +2 -1
  62. data/spec/internal/app/indices/product_index.rb +0 -2
  63. data/spec/internal/app/models/categorisation.rb +8 -1
  64. data/spec/spec_helper.rb +2 -0
  65. data/spec/support/json_column.rb +5 -1
  66. data/spec/support/multi_schema.rb +3 -1
  67. data/spec/support/sphinx_yaml_helpers.rb +1 -1
  68. data/spec/thinking_sphinx/active_record/association_spec.rb +1 -1
  69. data/spec/thinking_sphinx/active_record/attribute/type_spec.rb +41 -38
  70. data/spec/thinking_sphinx/active_record/base_spec.rb +29 -29
  71. data/spec/thinking_sphinx/active_record/callbacks/delete_callbacks_spec.rb +10 -10
  72. data/spec/thinking_sphinx/active_record/callbacks/delta_callbacks_spec.rb +48 -25
  73. data/spec/thinking_sphinx/active_record/callbacks/update_callbacks_spec.rb +8 -8
  74. data/spec/thinking_sphinx/active_record/column_spec.rb +13 -13
  75. data/spec/thinking_sphinx/active_record/column_sql_presenter_spec.rb +5 -5
  76. data/spec/thinking_sphinx/active_record/database_adapters/abstract_adapter_spec.rb +5 -5
  77. data/spec/thinking_sphinx/active_record/database_adapters/mysql_adapter_spec.rb +11 -11
  78. data/spec/thinking_sphinx/active_record/database_adapters/postgresql_adapter_spec.rb +13 -13
  79. data/spec/thinking_sphinx/active_record/database_adapters_spec.rb +48 -48
  80. data/spec/thinking_sphinx/active_record/field_spec.rb +7 -7
  81. data/spec/thinking_sphinx/active_record/filter_reflection_spec.rb +32 -32
  82. data/spec/thinking_sphinx/active_record/index_spec.rb +35 -36
  83. data/spec/thinking_sphinx/active_record/interpreter_spec.rb +51 -51
  84. data/spec/thinking_sphinx/active_record/polymorpher_spec.rb +14 -14
  85. data/spec/thinking_sphinx/active_record/property_sql_presenter_spec.rb +67 -67
  86. data/spec/thinking_sphinx/active_record/sql_builder_spec.rb +140 -140
  87. data/spec/thinking_sphinx/active_record/sql_source_spec.rb +97 -95
  88. data/spec/thinking_sphinx/configuration_spec.rb +81 -81
  89. data/spec/thinking_sphinx/connection_spec.rb +13 -13
  90. data/spec/thinking_sphinx/deletion_spec.rb +11 -11
  91. data/spec/thinking_sphinx/deltas/default_delta_spec.rb +20 -20
  92. data/spec/thinking_sphinx/deltas_spec.rb +12 -12
  93. data/spec/thinking_sphinx/errors_spec.rb +30 -30
  94. data/spec/thinking_sphinx/excerpter_spec.rb +7 -7
  95. data/spec/thinking_sphinx/facet_search_spec.rb +16 -16
  96. data/spec/thinking_sphinx/index_set_spec.rb +7 -7
  97. data/spec/thinking_sphinx/index_spec.rb +24 -24
  98. data/spec/thinking_sphinx/masks/pagination_mask_spec.rb +20 -20
  99. data/spec/thinking_sphinx/masks/scopes_mask_spec.rb +18 -18
  100. data/spec/thinking_sphinx/middlewares/active_record_translator_spec.rb +22 -22
  101. data/spec/thinking_sphinx/middlewares/geographer_spec.rb +9 -9
  102. data/spec/thinking_sphinx/middlewares/glazier_spec.rb +4 -4
  103. data/spec/thinking_sphinx/middlewares/inquirer_spec.rb +7 -7
  104. data/spec/thinking_sphinx/middlewares/sphinxql_spec.rb +53 -53
  105. data/spec/thinking_sphinx/middlewares/stale_id_checker_spec.rb +5 -5
  106. data/spec/thinking_sphinx/middlewares/stale_id_filter_spec.rb +15 -15
  107. data/spec/thinking_sphinx/panes/attributes_pane_spec.rb +1 -1
  108. data/spec/thinking_sphinx/panes/distance_pane_spec.rb +4 -4
  109. data/spec/thinking_sphinx/panes/excerpts_pane_spec.rb +5 -5
  110. data/spec/thinking_sphinx/panes/weight_pane_spec.rb +1 -1
  111. data/spec/thinking_sphinx/rake_interface_spec.rb +66 -53
  112. data/spec/thinking_sphinx/real_time/attribute_spec.rb +13 -13
  113. data/spec/thinking_sphinx/real_time/callbacks/real_time_callbacks_spec.rb +107 -23
  114. data/spec/thinking_sphinx/real_time/field_spec.rb +14 -14
  115. data/spec/thinking_sphinx/real_time/index_spec.rb +29 -30
  116. data/spec/thinking_sphinx/real_time/interpreter_spec.rb +30 -30
  117. data/spec/thinking_sphinx/scopes_spec.rb +5 -5
  118. data/spec/thinking_sphinx/search/glaze_spec.rb +15 -15
  119. data/spec/thinking_sphinx/search/query_spec.rb +10 -10
  120. data/spec/thinking_sphinx/search_spec.rb +28 -28
  121. data/spec/thinking_sphinx/wildcard_spec.rb +16 -11
  122. data/spec/thinking_sphinx_spec.rb +6 -6
  123. data/thinking-sphinx.gemspec +4 -4
  124. metadata +12 -9
@@ -10,8 +10,8 @@ describe 'Accessing excerpts for methods on a search result', :live => true do
10
10
  search = Book.search('gods')
11
11
  search.context[:panes] << ThinkingSphinx::Panes::ExcerptsPane
12
12
 
13
- search.first.excerpts.title.
14
- should == 'American <span class="match">Gods</span>'
13
+ expect(search.first.excerpts.title).
14
+ to eq('American <span class="match">Gods</span>')
15
15
  end
16
16
 
17
17
  it "handles UTF-8 text for excerpts" do
@@ -21,8 +21,8 @@ describe 'Accessing excerpts for methods on a search result', :live => true do
21
21
  search = Book.search 'миръ'
22
22
  search.context[:panes] << ThinkingSphinx::Panes::ExcerptsPane
23
23
 
24
- search.first.excerpts.title.
25
- should == 'Война и <span class="match">миръ</span>'
24
+ expect(search.first.excerpts.title).
25
+ to eq('Война и <span class="match">миръ</span>')
26
26
  end if ENV['SPHINX_VERSION'].try :[], /2.2.\d/
27
27
 
28
28
  it "does not include class names in excerpts" do
@@ -32,8 +32,8 @@ describe 'Accessing excerpts for methods on a search result', :live => true do
32
32
  search = Book.search('graveyard')
33
33
  search.context[:panes] << ThinkingSphinx::Panes::ExcerptsPane
34
34
 
35
- search.first.excerpts.title.
36
- should == 'The <span class="match">Graveyard</span> Book'
35
+ expect(search.first.excerpts.title).
36
+ to eq('The <span class="match">Graveyard</span> Book')
37
37
  end
38
38
 
39
39
  it "respects the star option with queries" do
@@ -43,7 +43,7 @@ describe 'Accessing excerpts for methods on a search result', :live => true do
43
43
  search = Article.search('thin', :star => true)
44
44
  search.context[:panes] << ThinkingSphinx::Panes::ExcerptsPane
45
45
 
46
- search.first.excerpts.title.
47
- should == '<span class="match">Something</span>'
46
+ expect(search.first.excerpts.title).
47
+ to eq('<span class="match">Something</span>')
48
48
  end
49
49
  end
@@ -16,9 +16,9 @@ describe 'Faceted searching', :live => true do
16
16
  Tee.create! :colour => green
17
17
  index
18
18
 
19
- Tee.facets.to_hash[:colour_id].should == {
19
+ expect(Tee.facets.to_hash[:colour_id]).to eq({
20
20
  blue.id => 2, red.id => 1, green.id => 3
21
- }
21
+ })
22
22
  end
23
23
 
24
24
  it "provides facet breakdowns across classes" do
@@ -30,9 +30,9 @@ describe 'Faceted searching', :live => true do
30
30
 
31
31
  article_count = ENV['SPHINX_VERSION'].try(:[], /2.0.\d/) ? 2 : 1
32
32
 
33
- ThinkingSphinx.facets.to_hash[:class].should == {
33
+ expect(ThinkingSphinx.facets.to_hash[:class]).to eq({
34
34
  'Tee' => 2, 'City' => 1, 'Article' => article_count
35
- }
35
+ })
36
36
  end
37
37
 
38
38
  it "handles field facets" do
@@ -42,9 +42,9 @@ describe 'Faceted searching', :live => true do
42
42
  Book.create! :title => '1Q84', :author => '村上 春樹'
43
43
  index
44
44
 
45
- Book.facets.to_hash[:author].should == {
45
+ expect(Book.facets.to_hash[:author]).to eq({
46
46
  'Neil Gaiman' => 2, 'Terry Pratchett' => 1, '村上 春樹' => 1
47
- }
47
+ })
48
48
  end
49
49
 
50
50
  it "handles MVA facets" do
@@ -62,9 +62,9 @@ describe 'Faceted searching', :live => true do
62
62
  :tag => pancakes
63
63
  index
64
64
 
65
- User.facets.to_hash[:tag_ids].should == {
65
+ expect(User.facets.to_hash[:tag_ids]).to eq({
66
66
  pancakes.id => 2, waffles.id => 1
67
- }
67
+ })
68
68
  end
69
69
 
70
70
  it "can filter on integer facet results" do
@@ -76,7 +76,7 @@ describe 'Faceted searching', :live => true do
76
76
  r1 = Tee.create! :colour => red
77
77
  index
78
78
 
79
- Tee.facets.for(:colour_id => blue.id).to_a.should == [b1, b2]
79
+ expect(Tee.facets.for(:colour_id => blue.id).to_a).to eq([b1, b2])
80
80
  end
81
81
 
82
82
  it "can filter on MVA facet results" do
@@ -91,7 +91,7 @@ describe 'Faceted searching', :live => true do
91
91
  Tagging.create! :article => Article.create!(:user => u2), :tag => pancakes
92
92
  index
93
93
 
94
- User.facets.for(:tag_ids => waffles.id).to_a.should == [u1]
94
+ expect(User.facets.for(:tag_ids => waffles.id).to_a).to eq([u1])
95
95
  end
96
96
 
97
97
  it "can filter on string facet results" do
@@ -100,7 +100,7 @@ describe 'Faceted searching', :live => true do
100
100
  snuff = Book.create! :title => 'Snuff', :author => 'Terry Pratchett'
101
101
  index
102
102
 
103
- Book.facets.for(:author => 'Neil Gaiman').to_a.should == [gods, boys]
103
+ expect(Book.facets.for(:author => 'Neil Gaiman').to_a).to eq([gods, boys])
104
104
  end
105
105
 
106
106
  it "allows enumeration" do
@@ -119,8 +119,8 @@ describe 'Faceted searching', :live => true do
119
119
  [:class, {'Tee' => 3}]
120
120
  ]
121
121
  Tee.facets.each do |facet, hash|
122
- facet.should == expectations[calls].first
123
- hash.should == expectations[calls].last
122
+ expect(facet).to eq(expectations[calls].first)
123
+ expect(hash).to eq(expectations[calls].last)
124
124
 
125
125
  calls += 1
126
126
  end
@@ -7,8 +7,8 @@ describe 'Searching by latitude and longitude', :live => true do
7
7
  bri = City.create :name => 'Brisbane', :lat => -0.4794031, :lng => 2.670838
8
8
  index
9
9
 
10
- City.search(:geo => [-0.616241, 2.602712], :order => 'geodist ASC').
11
- to_a.should == [syd, mel, bri]
10
+ expect(City.search(:geo => [-0.616241, 2.602712], :order => 'geodist ASC').
11
+ to_a).to eq([syd, mel, bri])
12
12
  end
13
13
 
14
14
  it "filters by distance" do
@@ -17,10 +17,10 @@ describe 'Searching by latitude and longitude', :live => true do
17
17
  bri = City.create :name => 'Brisbane', :lat => -0.4794031, :lng => 2.670838
18
18
  index
19
19
 
20
- City.search(
20
+ expect(City.search(
21
21
  :geo => [-0.616241, 2.602712],
22
22
  :with => {:geodist => 0.0..470_000.0}
23
- ).to_a.should == [mel, syd]
23
+ ).to_a).to eq([mel, syd])
24
24
  end
25
25
 
26
26
  it "provides the distance for each search result" do
@@ -37,9 +37,9 @@ describe 'Searching by latitude and longitude', :live => true do
37
37
  end
38
38
 
39
39
  if ActiveRecord::Base.configurations['test']['adapter'][/postgres/]
40
- cities.first.geodist.should == expected[:postgresql]
40
+ expect(cities.first.geodist).to eq(expected[:postgresql])
41
41
  else # mysql
42
- cities.first.geodist.should == expected[:mysql]
42
+ expect(cities.first.geodist).to eq(expected[:mysql])
43
43
  end
44
44
  end
45
45
 
@@ -49,10 +49,10 @@ describe 'Searching by latitude and longitude', :live => true do
49
49
  bri = City.create :name => 'Brisbane', :lat => -0.4794031, :lng => 2.670838
50
50
  index
51
51
 
52
- City.search(
52
+ expect(City.search(
53
53
  :geo => [-0.616241, 2.602712],
54
54
  :with => {:geodist => 0.0..470_000.0},
55
55
  :select => "*, geodist as custom_weight"
56
- ).to_a.should == [mel, syd]
56
+ ).to_a).to eq([mel, syd])
57
57
  end
58
58
  end
@@ -8,7 +8,7 @@ describe 'Grouping search results by attributes', :live => true do
8
8
 
9
9
  index
10
10
 
11
- Book.search(:group_by => :year).to_a.should == [snuff, earth]
11
+ expect(Book.search(:group_by => :year).to_a).to eq([snuff, earth])
12
12
  end
13
13
 
14
14
  it "allows sorting within the group" do
@@ -18,8 +18,8 @@ describe 'Grouping search results by attributes', :live => true do
18
18
 
19
19
  index
20
20
 
21
- Book.search(:group_by => :year, :order_group_by => 'title ASC').to_a.
22
- should == [snuff, dodger]
21
+ expect(Book.search(:group_by => :year, :order_group_by => 'title ASC').to_a).
22
+ to eq([snuff, dodger])
23
23
  end
24
24
 
25
25
  it "allows enumerating by count" do
@@ -34,8 +34,8 @@ describe 'Grouping search results by attributes', :live => true do
34
34
  Book.search(:group_by => :year).each_with_count do |book, count|
35
35
  expectation = expectations.shift
36
36
 
37
- book.should == expectation.first
38
- count.should == expectation.last
37
+ expect(book).to eq(expectation.first)
38
+ expect(count).to eq(expectation.last)
39
39
  end
40
40
  end
41
41
 
@@ -51,8 +51,8 @@ describe 'Grouping search results by attributes', :live => true do
51
51
  Book.search(:group_by => :year).each_with_group do |book, group|
52
52
  expectation = expectations.shift
53
53
 
54
- book.should == expectation.first
55
- group.should == expectation.last
54
+ expect(book).to eq(expectation.first)
55
+ expect(group).to eq(expectation.last)
56
56
  end
57
57
  end
58
58
 
@@ -69,9 +69,9 @@ describe 'Grouping search results by attributes', :live => true do
69
69
  search.each_with_group_and_count do |book, group, count|
70
70
  expectation = expectations.shift
71
71
 
72
- book.should == expectation[0]
73
- group.should == expectation[1]
74
- count.should == expectation[2]
72
+ expect(book).to eq(expectation[0])
73
+ expect(group).to eq(expectation[1])
74
+ expect(count).to eq(expectation[2])
75
75
  end
76
76
  end
77
77
  end
@@ -14,11 +14,11 @@ describe 'Index options' do
14
14
  end
15
15
 
16
16
  it "keeps #{type}_fields blank" do
17
- index.send("#{type}_fields").should be_nil
17
+ expect(index.send("#{type}_fields")).to be_nil
18
18
  end
19
19
 
20
20
  it "sets min_#{type}_len" do
21
- index.send("min_#{type}_len").should == 3
21
+ expect(index.send("min_#{type}_len")).to eq(3)
22
22
  end
23
23
  end
24
24
 
@@ -33,11 +33,11 @@ describe 'Index options' do
33
33
  end
34
34
 
35
35
  it "#{type}_fields should contain the field" do
36
- index.send("#{type}_fields").should == 'title'
36
+ expect(index.send("#{type}_fields")).to eq('title')
37
37
  end
38
38
 
39
39
  it "sets min_#{type}_len" do
40
- index.send("min_#{type}_len").should == 3
40
+ expect(index.send("min_#{type}_len")).to eq(3)
41
41
  end
42
42
  end
43
43
  end
@@ -57,12 +57,12 @@ describe 'Index options' do
57
57
  end
58
58
 
59
59
  it "stores each source definition" do
60
- index.sources.length.should == 2
60
+ expect(index.sources.length).to eq(2)
61
61
  end
62
62
 
63
63
  it "treats each source as separate" do
64
- index.sources.first.fields.length.should == 2
65
- index.sources.last.fields.length.should == 3
64
+ expect(index.sources.first.fields.length).to eq(2)
65
+ expect(index.sources.last.fields.length).to eq(3)
66
66
  end
67
67
  end
68
68
 
@@ -77,11 +77,11 @@ describe 'Index options' do
77
77
  end
78
78
 
79
79
  it "declares wordcount fields" do
80
- index.sources.first.sql_field_str2wordcount.should == ['title']
80
+ expect(index.sources.first.sql_field_str2wordcount).to eq(['title'])
81
81
  end
82
82
 
83
83
  it "declares wordcount attributes" do
84
- index.sources.first.sql_attr_str2wordcount.should == ['content']
84
+ expect(index.sources.first.sql_attr_str2wordcount).to eq(['content'])
85
85
  end
86
86
  end
87
87
 
@@ -98,15 +98,15 @@ describe 'Index options' do
98
98
  end
99
99
 
100
100
  it "allows for core source settings" do
101
- index.sources.first.sql_range_step.should == 5
101
+ expect(index.sources.first.sql_range_step).to eq(5)
102
102
  end
103
103
 
104
104
  it "allows for source options" do
105
- index.sources.first.disable_range?.should be_true
105
+ expect(index.sources.first.disable_range?).to be_truthy
106
106
  end
107
107
 
108
108
  it "respects sql_query_pre values" do
109
- index.sources.first.sql_query_pre.should include("DO STUFF")
109
+ expect(index.sources.first.sql_query_pre).to include("DO STUFF")
110
110
  end
111
111
  end
112
112
 
@@ -130,23 +130,23 @@ describe 'Index options' do
130
130
  end
131
131
 
132
132
  it "prioritises index-level options over YAML options" do
133
- index.min_infix_len.should == 1
133
+ expect(index.min_infix_len).to eq(1)
134
134
  end
135
135
 
136
136
  it "prioritises index-level source options" do
137
- index.sources.first.sql_range_step.should == 20
137
+ expect(index.sources.first.sql_range_step).to eq(20)
138
138
  end
139
139
 
140
140
  it "keeps index-level options prioritised when rendered again" do
141
141
  index.render
142
142
 
143
- index.min_infix_len.should == 1
143
+ expect(index.min_infix_len).to eq(1)
144
144
  end
145
145
 
146
146
  it "keeps index-level options prioritised when rendered again" do
147
147
  index.render
148
148
 
149
- index.sources.first.sql_range_step.should == 20
149
+ expect(index.sources.first.sql_range_step).to eq(20)
150
150
  end
151
151
  end
152
152
  end
@@ -8,7 +8,7 @@ describe 'Indexing', :live => true do
8
8
 
9
9
  article = Article.create! :title => 'Pancakes'
10
10
  index 'article_core'
11
- Article.search.should be_empty
11
+ expect(Article.search).to be_empty
12
12
 
13
13
  FileUtils.rm path
14
14
  end
@@ -20,7 +20,7 @@ describe 'Indexing', :live => true do
20
20
 
21
21
  article = Article.create! :title => 'Pancakes'
22
22
  index 'article_core'
23
- Article.search.should_not be_empty
23
+ expect(Article.search).not_to be_empty
24
24
 
25
25
  FileUtils.rm path
26
26
  end
@@ -31,6 +31,6 @@ describe 'Indexing', :live => true do
31
31
  index 'article_core'
32
32
 
33
33
  file = Rails.root.join('db/sphinx/test/ts-article_core.tmp')
34
- File.exist?(file).should be_false
34
+ expect(File.exist?(file)).to be_falsey
35
35
  end
36
36
  end
@@ -5,20 +5,20 @@ describe 'Paginating search results', :live => true do
5
5
  21.times { |number| Article.create :title => "Article #{number}" }
6
6
  index
7
7
 
8
- Article.search.total_entries.should == 21
8
+ expect(Article.search.total_entries).to eq(21)
9
9
  end
10
10
 
11
11
  it "paginates the result set by default" do
12
12
  21.times { |number| Article.create :title => "Article #{number}" }
13
13
  index
14
14
 
15
- Article.search.length.should == 20
15
+ expect(Article.search.length).to eq(20)
16
16
  end
17
17
 
18
18
  it "tracks the number of pages" do
19
19
  21.times { |number| Article.create :title => "Article #{number}" }
20
20
  index
21
21
 
22
- Article.search.total_pages.should == 2
22
+ expect(Article.search.total_pages).to eq(2)
23
23
  end
24
24
  end
@@ -4,14 +4,14 @@ describe 'Updates to records in real-time indices', :live => true do
4
4
  it "handles fields with unicode nulls" do
5
5
  product = Product.create! :name => "Widget \u0000"
6
6
 
7
- Product.search.first.should == product
8
- end
7
+ expect(Product.search.first).to eq(product)
8
+ end unless ENV['DATABASE'] == 'postgresql'
9
9
 
10
10
  it "handles attributes for sortable fields accordingly" do
11
11
  product = Product.create! :name => 'Red Fish'
12
12
  product.update_attributes :name => 'Blue Fish'
13
13
 
14
- Product.search('blue fish', :indices => ['product_core']).to_a.
15
- should == [product]
14
+ expect(Product.search('blue fish', :indices => ['product_core']).to_a).
15
+ to eq([product])
16
16
  end
17
17
  end
@@ -5,47 +5,47 @@ describe 'Hiding deleted records from search results', :live => true do
5
5
  pancakes = Article.create! :title => 'Pancakes'
6
6
  index
7
7
 
8
- Article.search('pancakes').should_not be_empty
8
+ expect(Article.search('pancakes')).not_to be_empty
9
9
  pancakes.destroy
10
10
 
11
- Article.search('pancakes').should be_empty
11
+ expect(Article.search('pancakes')).to be_empty
12
12
  end
13
13
 
14
14
  it "will catch stale records deleted without callbacks being fired" do
15
15
  pancakes = Article.create! :title => 'Pancakes'
16
16
  index
17
17
 
18
- Article.search('pancakes').should_not be_empty
18
+ expect(Article.search('pancakes')).not_to be_empty
19
19
  Article.connection.execute "DELETE FROM articles WHERE id = #{pancakes.id}"
20
20
 
21
- Article.search('pancakes').should be_empty
21
+ expect(Article.search('pancakes')).to be_empty
22
22
  end
23
23
 
24
24
  it "removes records from real-time index results" do
25
25
  product = Product.create! :name => 'Shiny'
26
26
 
27
- Product.search('Shiny', :indices => ['product_core']).to_a.
28
- should == [product]
27
+ expect(Product.search('Shiny', :indices => ['product_core']).to_a).
28
+ to eq([product])
29
29
 
30
30
  product.destroy
31
31
 
32
- Product.search_for_ids('Shiny', :indices => ['product_core']).
33
- should be_empty
32
+ expect(Product.search_for_ids('Shiny', :indices => ['product_core'])).
33
+ to be_empty
34
34
  end
35
35
 
36
36
  it "does not remove real-time results when callbacks are disabled" do
37
37
  original = ThinkingSphinx::Configuration.instance.
38
38
  settings['real_time_callbacks']
39
39
  product = Product.create! :name => 'Shiny'
40
- Product.search('Shiny', :indices => ['product_core']).to_a.
41
- should == [product]
40
+ expect(Product.search('Shiny', :indices => ['product_core']).to_a).
41
+ to eq([product])
42
42
 
43
43
  ThinkingSphinx::Configuration.instance.
44
44
  settings['real_time_callbacks'] = false
45
45
 
46
46
  product.destroy
47
- Product.search_for_ids('Shiny', :indices => ['product_core']).
48
- should_not be_empty
47
+ expect(Product.search_for_ids('Shiny', :indices => ['product_core'])).
48
+ not_to be_empty
49
49
 
50
50
  ThinkingSphinx::Configuration.instance.
51
51
  settings['real_time_callbacks'] = original