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
@@ -5,7 +5,7 @@ describe 'Get search result counts', :live => true do
5
5
  4.times { |i| Article.create :title => "Article #{i}" }
6
6
  index
7
7
 
8
- Article.search_count.should == 4
8
+ expect(Article.search_count).to eq(4)
9
9
  end
10
10
 
11
11
  it "returns counts across all models" do
@@ -13,6 +13,6 @@ describe 'Get search result counts', :live => true do
13
13
  2.times { |i| Book.create :title => "Book #{i}" }
14
14
  index
15
15
 
16
- ThinkingSphinx.count.should == 5
16
+ expect(ThinkingSphinx.count).to eq(5)
17
17
  end
18
18
  end
@@ -6,7 +6,7 @@ describe 'Searching for just instance Ids', :live => true do
6
6
  waffles = Article.create! :title => 'Waffles'
7
7
  index
8
8
 
9
- Article.search_for_ids('pancakes').to_a.should == [pancakes.id]
9
+ expect(Article.search_for_ids('pancakes').to_a).to eq([pancakes.id])
10
10
  end
11
11
 
12
12
  it "works across the global context" do
@@ -14,6 +14,6 @@ describe 'Searching for just instance Ids', :live => true do
14
14
  book = Book.create! :title => 'American Gods'
15
15
  index
16
16
 
17
- ThinkingSphinx.search_for_ids.to_a.should =~ [article.id, book.id]
17
+ expect(ThinkingSphinx.search_for_ids.to_a).to match_array([article.id, book.id])
18
18
  end
19
19
  end
@@ -5,7 +5,7 @@ describe 'Searching across models', :live => true do
5
5
  article = Article.create! :title => 'Pancakes'
6
6
  index
7
7
 
8
- ThinkingSphinx.search.first.should == article
8
+ expect(ThinkingSphinx.search.first).to eq(article)
9
9
  end
10
10
 
11
11
  it "returns results matching the given query" do
@@ -14,8 +14,8 @@ describe 'Searching across models', :live => true do
14
14
  index
15
15
 
16
16
  articles = ThinkingSphinx.search 'pancakes'
17
- articles.should include(pancakes)
18
- articles.should_not include(waffles)
17
+ expect(articles).to include(pancakes)
18
+ expect(articles).not_to include(waffles)
19
19
  end
20
20
 
21
21
  it "handles results from different models" do
@@ -23,7 +23,7 @@ describe 'Searching across models', :live => true do
23
23
  book = Book.create! :title => 'American Gods'
24
24
  index
25
25
 
26
- ThinkingSphinx.search.to_a.should =~ [article, book]
26
+ expect(ThinkingSphinx.search.to_a).to match_array([article, book])
27
27
  end
28
28
 
29
29
  it "filters by multiple classes" do
@@ -32,7 +32,7 @@ describe 'Searching across models', :live => true do
32
32
  user = User.create! :name => 'Pat'
33
33
  index
34
34
 
35
- ThinkingSphinx.search(:classes => [User, Article]).to_a.
36
- should =~ [article, user]
35
+ expect(ThinkingSphinx.search(:classes => [User, Article]).to_a).
36
+ to match_array([article, user])
37
37
  end
38
38
  end
@@ -16,23 +16,23 @@ describe 'Searching across PostgreSQL schemas', :live => true do
16
16
  it 'can distinguish between objects with the same primary key' do
17
17
  multi_schema.switch :public
18
18
  jekyll = Product.create name: 'Doctor Jekyll'
19
- Product.search('Jekyll', :retry_stale => false).to_a.should == [jekyll]
20
- Product.search(:retry_stale => false).to_a.should == [jekyll]
19
+ expect(Product.search('Jekyll', :retry_stale => false).to_a).to eq([jekyll])
20
+ expect(Product.search(:retry_stale => false).to_a).to eq([jekyll])
21
21
 
22
22
  multi_schema.switch :thinking_sphinx
23
23
  hyde = Product.create name: 'Mister Hyde'
24
- Product.search('Jekyll', :retry_stale => false).to_a.should == []
25
- Product.search('Hyde', :retry_stale => false).to_a.should == [hyde]
26
- Product.search(:retry_stale => false).to_a.should == [hyde]
24
+ expect(Product.search('Jekyll', :retry_stale => false).to_a).to eq([])
25
+ expect(Product.search('Hyde', :retry_stale => false).to_a).to eq([hyde])
26
+ expect(Product.search(:retry_stale => false).to_a).to eq([hyde])
27
27
 
28
28
  multi_schema.switch :public
29
- Product.search('Jekyll', :retry_stale => false).to_a.should == [jekyll]
30
- Product.search(:retry_stale => false).to_a.should == [jekyll]
31
- Product.search('Hyde', :retry_stale => false).to_a.should == []
29
+ expect(Product.search('Jekyll', :retry_stale => false).to_a).to eq([jekyll])
30
+ expect(Product.search(:retry_stale => false).to_a).to eq([jekyll])
31
+ expect(Product.search('Hyde', :retry_stale => false).to_a).to eq([])
32
32
 
33
- Product.search(
33
+ expect(Product.search(
34
34
  :middleware => ThinkingSphinx::Middlewares::RAW_ONLY,
35
35
  :indices => ['product_core', 'product_two_core']
36
- ).to_a.length.should == 2
36
+ ).to_a.length).to eq(2)
37
37
  end
38
38
  end if multi_schema.active?
@@ -8,8 +8,8 @@ describe 'Searching on fields', :live => true do
8
8
  index
9
9
 
10
10
  articles = Article.search :conditions => {:title => 'pancakes'}
11
- articles.should include(pancakes)
12
- articles.should_not include(waffles)
11
+ expect(articles).to include(pancakes)
12
+ expect(articles).not_to include(waffles)
13
13
  end
14
14
 
15
15
  it "limits results for a field from an association" do
@@ -17,7 +17,7 @@ describe 'Searching on fields', :live => true do
17
17
  pancakes = Article.create! :title => 'Pancakes', :user => user
18
18
  index
19
19
 
20
- Article.search(:conditions => {:user => 'pat'}).first.should == pancakes
20
+ expect(Article.search(:conditions => {:user => 'pat'}).first).to eq(pancakes)
21
21
  end
22
22
 
23
23
  it "returns results with matches from grouped fields" do
@@ -26,23 +26,23 @@ describe 'Searching on fields', :live => true do
26
26
  waffles = Article.create! :title => 'Waffles', :user => user
27
27
  index
28
28
 
29
- Article.search('waffles', :conditions => {:title => 'pancakes'}).to_a.
30
- should == [pancakes]
29
+ expect(Article.search('waffles', :conditions => {:title => 'pancakes'}).to_a).
30
+ to eq([pancakes])
31
31
  end
32
32
 
33
33
  it "returns results with matches from concatenated columns in a field" do
34
34
  book = Book.create! :title => 'Night Watch', :author => 'Terry Pratchett'
35
35
  index
36
36
 
37
- Book.search(:conditions => {:info => 'Night Pratchett'}).to_a.
38
- should == [book]
37
+ expect(Book.search(:conditions => {:info => 'Night Pratchett'}).to_a).
38
+ to eq([book])
39
39
  end
40
40
 
41
41
  it "handles NULLs in concatenated fields" do
42
42
  book = Book.create! :title => 'Night Watch'
43
43
  index
44
44
 
45
- Book.search(:conditions => {:info => 'Night Watch'}).to_a.should == [book]
45
+ expect(Book.search(:conditions => {:info => 'Night Watch'}).to_a).to eq([book])
46
46
  end
47
47
 
48
48
  it "returns results with matches from file fields" do
@@ -52,6 +52,6 @@ describe 'Searching on fields', :live => true do
52
52
  book = Book.create! :title => 'Accelerando', :blurb_file => file_path.to_s
53
53
  index
54
54
 
55
- Book.search('cyberpunk').to_a.should == [book]
55
+ expect(Book.search('cyberpunk').to_a).to eq([book])
56
56
  end
57
57
  end
@@ -6,7 +6,7 @@ describe 'Searching with filters', :live => true do
6
6
  waffles = Article.create! :title => 'Waffles', :published => false
7
7
  index
8
8
 
9
- Article.search(:with => {:published => true}).to_a.should == [pancakes]
9
+ expect(Article.search(:with => {:published => true}).to_a).to eq([pancakes])
10
10
  end
11
11
 
12
12
  it "limits results by an array of values" do
@@ -15,7 +15,7 @@ describe 'Searching with filters', :live => true do
15
15
  grave = Book.create! :title => 'The Graveyard Book', :year => 2009
16
16
  index
17
17
 
18
- Book.search(:with => {:year => [2001, 2005]}).to_a.should == [gods, boys]
18
+ expect(Book.search(:with => {:year => [2001, 2005]}).to_a).to eq([gods, boys])
19
19
  end
20
20
 
21
21
  it "limits results by a ranged filter" do
@@ -28,8 +28,8 @@ describe 'Searching with filters', :live => true do
28
28
  grave.update_column :created_at, 1.day.ago
29
29
  index
30
30
 
31
- Book.search(:with => {:created_at => 6.days.ago..2.days.ago}).to_a.
32
- should == [gods, boys]
31
+ expect(Book.search(:with => {:created_at => 6.days.ago..2.days.ago}).to_a).
32
+ to eq([gods, boys])
33
33
  end
34
34
 
35
35
  it "limits results by exclusive filters on single values" do
@@ -37,7 +37,7 @@ describe 'Searching with filters', :live => true do
37
37
  waffles = Article.create! :title => 'Waffles', :published => false
38
38
  index
39
39
 
40
- Article.search(:without => {:published => true}).to_a.should == [waffles]
40
+ expect(Article.search(:without => {:published => true}).to_a).to eq([waffles])
41
41
  end
42
42
 
43
43
  it "limits results by exclusive filters on arrays of values" do
@@ -46,7 +46,7 @@ describe 'Searching with filters', :live => true do
46
46
  grave = Book.create! :title => 'The Graveyard Book', :year => 2009
47
47
  index
48
48
 
49
- Book.search(:without => {:year => [2001, 2005]}).to_a.should == [grave]
49
+ expect(Book.search(:without => {:year => [2001, 2005]}).to_a).to eq([grave])
50
50
  end
51
51
 
52
52
  it "limits results by ranged filters on timestamp MVAs" do
@@ -64,9 +64,9 @@ describe 'Searching with filters', :live => true do
64
64
 
65
65
  index
66
66
 
67
- Article.search(
67
+ expect(Article.search(
68
68
  :with => {:taggings_at => 1.days.ago..1.day.from_now}
69
- ).to_a.should == [pancakes]
69
+ ).to_a).to eq([pancakes])
70
70
  end
71
71
 
72
72
  it "takes into account local timezones for timestamps" do
@@ -84,9 +84,9 @@ describe 'Searching with filters', :live => true do
84
84
 
85
85
  index
86
86
 
87
- Article.search(
87
+ expect(Article.search(
88
88
  :with => {:taggings_at => 2.minutes.ago..Time.zone.now}
89
- ).to_a.should == [pancakes]
89
+ ).to_a).to eq([pancakes])
90
90
  end
91
91
 
92
92
  it "limits results with MVAs having all of the given values" do
@@ -103,13 +103,13 @@ describe 'Searching with filters', :live => true do
103
103
  index
104
104
 
105
105
  articles = Article.search :with_all => {:tag_ids => [food.id, flat.id]}
106
- articles.to_a.should == [pancakes]
106
+ expect(articles.to_a).to eq([pancakes])
107
107
  end
108
108
 
109
109
  it "limits results with MVAs that don't contain all the given values" do
110
110
  # Matching results may have some of the given values, but cannot have all
111
111
  # of them. Certainly an edge case.
112
- pending "SphinxQL doesn't yet support OR in its WHERE clause"
112
+ skip "SphinxQL doesn't yet support OR in its WHERE clause"
113
113
 
114
114
  pancakes = Article.create :title => 'Pancakes'
115
115
  waffles = Article.create :title => 'Waffles'
@@ -124,7 +124,7 @@ describe 'Searching with filters', :live => true do
124
124
  index
125
125
 
126
126
  articles = Article.search :without_all => {:tag_ids => [food.id, flat.id]}
127
- articles.to_a.should == [waffles]
127
+ expect(articles.to_a).to eq([waffles])
128
128
  end
129
129
 
130
130
  it "limits results on real-time indices with multi-value integer attributes" do
@@ -139,7 +139,7 @@ describe 'Searching with filters', :live => true do
139
139
  waffles.categories << food
140
140
 
141
141
  products = Product.search :with => {:category_ids => [flat.id]}
142
- products.to_a.should == [pancakes]
142
+ expect(products.to_a).to eq([pancakes])
143
143
  end
144
144
 
145
145
  it 'searches with real-time JSON attributes' do
@@ -149,9 +149,9 @@ describe 'Searching with filters', :live => true do
149
149
  :options => {'chocolate' => 1, 'sugar' => 1, :number => 1}
150
150
 
151
151
  products = Product.search :with => {"options.lemon" => 1}
152
- products.to_a.should == [pancakes]
152
+ expect(products.to_a).to eq([pancakes])
153
153
 
154
154
  products = Product.search :with => {"options.sugar" => 1}
155
- products.to_a.should == [pancakes, waffles]
155
+ expect(products.to_a).to eq([pancakes, waffles])
156
156
  end if JSONColumn.call
157
157
  end
@@ -6,7 +6,7 @@ describe 'Searching across STI models', :live => true do
6
6
  duck = Bird.create :name => 'Duck'
7
7
  index
8
8
 
9
- Animal.search(:indices => ['animal_core']).to_a.should == [platypus, duck]
9
+ expect(Animal.search(:indices => ['animal_core']).to_a).to eq([platypus, duck])
10
10
  end
11
11
 
12
12
  it "limits results based on subclasses" do
@@ -14,7 +14,7 @@ describe 'Searching across STI models', :live => true do
14
14
  duck = Bird.create :name => 'Duck'
15
15
  index
16
16
 
17
- Bird.search(:indices => ['animal_core']).to_a.should == [duck]
17
+ expect(Bird.search(:indices => ['animal_core']).to_a).to eq([duck])
18
18
  end
19
19
 
20
20
  it "returns results for deeper subclasses when searching on their parents" do
@@ -23,7 +23,7 @@ describe 'Searching across STI models', :live => true do
23
23
  emu = FlightlessBird.create :name => 'Emu'
24
24
  index
25
25
 
26
- Bird.search(:indices => ['animal_core']).to_a.should == [duck, emu]
26
+ expect(Bird.search(:indices => ['animal_core']).to_a).to eq([duck, emu])
27
27
  end
28
28
 
29
29
  it "returns results for deeper subclasses" do
@@ -32,7 +32,7 @@ describe 'Searching across STI models', :live => true do
32
32
  emu = FlightlessBird.create :name => 'Emu'
33
33
  index
34
34
 
35
- FlightlessBird.search(:indices => ['animal_core']).to_a.should == [emu]
35
+ expect(FlightlessBird.search(:indices => ['animal_core']).to_a).to eq([emu])
36
36
  end
37
37
 
38
38
  it "filters out sibling subclasses" do
@@ -41,7 +41,7 @@ describe 'Searching across STI models', :live => true do
41
41
  otter = Mammal.create :name => 'Otter'
42
42
  index
43
43
 
44
- Bird.search(:indices => ['animal_core']).to_a.should == [duck]
44
+ expect(Bird.search(:indices => ['animal_core']).to_a).to eq([duck])
45
45
  end
46
46
 
47
47
  it "obeys :classes if supplied" do
@@ -50,18 +50,18 @@ describe 'Searching across STI models', :live => true do
50
50
  emu = FlightlessBird.create :name => 'Emu'
51
51
  index
52
52
 
53
- Bird.search(
53
+ expect(Bird.search(
54
54
  :indices => ['animal_core'],
55
55
  :skip_sti => true,
56
56
  :classes => [Bird, FlightlessBird]
57
- ).to_a.should == [duck, emu]
57
+ ).to_a).to eq([duck, emu])
58
58
  end
59
59
 
60
60
  it 'finds root objects when type is blank' do
61
61
  animal = Animal.create :name => 'Animal', type: ''
62
62
  index
63
63
 
64
- Animal.search(:indices => ['animal_core']).to_a.should == [animal]
64
+ expect(Animal.search(:indices => ['animal_core']).to_a).to eq([animal])
65
65
  end
66
66
 
67
67
  it 'allows for indices on mid-hierarchy classes' do
@@ -69,6 +69,6 @@ describe 'Searching across STI models', :live => true do
69
69
  emu = FlightlessBird.create :name => 'Emu'
70
70
  index
71
71
 
72
- Bird.search(:indices => ['bird_core']).to_a.should == [duck, emu]
72
+ expect(Bird.search(:indices => ['bird_core']).to_a).to eq([duck, emu])
73
73
  end
74
74
  end
@@ -6,7 +6,7 @@ describe 'Searching within a model', :live => true do
6
6
  article = Article.create! :title => 'Pancakes'
7
7
  index
8
8
 
9
- Article.search.first.should == article
9
+ expect(Article.search.first).to eq(article)
10
10
  end
11
11
 
12
12
  it "returns results matching the given query" do
@@ -15,22 +15,22 @@ describe 'Searching within a model', :live => true do
15
15
  index
16
16
 
17
17
  articles = Article.search 'pancakes'
18
- articles.should include(pancakes)
19
- articles.should_not include(waffles)
18
+ expect(articles).to include(pancakes)
19
+ expect(articles).not_to include(waffles)
20
20
  end
21
21
 
22
22
  it "handles unicode characters" do
23
23
  istanbul = City.create! :name => 'İstanbul'
24
24
  index
25
25
 
26
- City.search('İstanbul').to_a.should == [istanbul]
26
+ expect(City.search('İstanbul').to_a).to eq([istanbul])
27
27
  end
28
28
 
29
29
  it "will star provided queries on request" do
30
30
  article = Article.create! :title => 'Pancakes'
31
31
  index
32
32
 
33
- Article.search('cake', :star => true).first.should == article
33
+ expect(Article.search('cake', :star => true).first).to eq(article)
34
34
  end
35
35
 
36
36
  it "allows for searching on specific indices" do
@@ -38,7 +38,7 @@ describe 'Searching within a model', :live => true do
38
38
  index
39
39
 
40
40
  articles = Article.search('pancake', :indices => ['stemmed_article_core'])
41
- articles.to_a.should == [article]
41
+ expect(articles.to_a).to eq([article])
42
42
  end
43
43
 
44
44
  it "allows for searching on distributed indices" do
@@ -46,38 +46,38 @@ describe 'Searching within a model', :live => true do
46
46
  index
47
47
 
48
48
  articles = Article.search('pancake', :indices => ['article'])
49
- articles.to_a.should == [article]
49
+ expect(articles.to_a).to eq([article])
50
50
  end
51
51
 
52
52
  it "can search on namespaced models" do
53
53
  person = Admin::Person.create :name => 'James Bond'
54
54
  index
55
55
 
56
- Admin::Person.search('Bond').to_a.should == [person]
56
+ expect(Admin::Person.search('Bond').to_a).to eq([person])
57
57
  end
58
58
 
59
59
  it "raises an error if searching through an ActiveRecord scope" do
60
- lambda {
60
+ expect {
61
61
  City.ordered.search
62
- }.should raise_error(ThinkingSphinx::MixedScopesError)
62
+ }.to raise_error(ThinkingSphinx::MixedScopesError)
63
63
  end
64
64
 
65
65
  it "does not raise an error when searching with a default ActiveRecord scope" do
66
- lambda {
66
+ expect {
67
67
  User.search
68
- }.should_not raise_error(ThinkingSphinx::MixedScopesError)
68
+ }.not_to raise_error
69
69
  end
70
70
 
71
71
  it "raises an error when searching with default and applied AR scopes" do
72
- lambda {
72
+ expect {
73
73
  User.recent.search
74
- }.should raise_error(ThinkingSphinx::MixedScopesError)
74
+ }.to raise_error(ThinkingSphinx::MixedScopesError)
75
75
  end
76
76
 
77
77
  it "raises an error if the model has no indices defined" do
78
- lambda {
78
+ expect {
79
79
  Category.search.to_a
80
- }.should raise_error(ThinkingSphinx::NoIndicesError)
80
+ }.to raise_error(ThinkingSphinx::NoIndicesError)
81
81
  end
82
82
  end
83
83
 
@@ -85,6 +85,6 @@ describe 'Searching within a model with a realtime index', :live => true do
85
85
  it "returns results" do
86
86
  product = Product.create! :name => 'Widget'
87
87
 
88
- Product.search.first.should == product
88
+ expect(Product.search.first).to eq(product)
89
89
  end
90
90
  end