chewy 0.5.2 → 0.6.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 (92) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +26 -4
  3. data/CHANGELOG.md +16 -0
  4. data/Gemfile +3 -1
  5. data/README.md +2 -10
  6. data/chewy.gemspec +0 -1
  7. data/gemfiles/Gemfile.rails-3.2.active_record +6 -0
  8. data/gemfiles/Gemfile.rails-3.2.active_record.kaminari +7 -0
  9. data/gemfiles/Gemfile.rails-3.2.active_record.will_paginate +7 -0
  10. data/gemfiles/Gemfile.rails-4.0.active_record +6 -0
  11. data/gemfiles/Gemfile.rails-4.0.active_record.kaminari +7 -0
  12. data/gemfiles/Gemfile.rails-4.0.active_record.will_paginate +7 -0
  13. data/gemfiles/Gemfile.rails-4.0.mongoid +6 -0
  14. data/gemfiles/Gemfile.rails-4.0.mongoid.kaminari +7 -0
  15. data/gemfiles/Gemfile.rails-4.0.mongoid.will_paginate +7 -0
  16. data/gemfiles/Gemfile.rails-4.1.active_record +6 -0
  17. data/gemfiles/Gemfile.rails-4.1.active_record.kaminari +7 -0
  18. data/gemfiles/Gemfile.rails-4.1.active_record.will_paginate +7 -0
  19. data/gemfiles/Gemfile.rails-4.1.mongoid +6 -0
  20. data/gemfiles/Gemfile.rails-4.1.mongoid.kaminari +7 -0
  21. data/gemfiles/Gemfile.rails-4.1.mongoid.will_paginate +7 -0
  22. data/gemfiles/Gemfile.rails-4.2.active_record +6 -0
  23. data/gemfiles/Gemfile.rails-4.2.active_record.kaminari +7 -0
  24. data/gemfiles/Gemfile.rails-4.2.active_record.will_paginate +7 -0
  25. data/gemfiles/Gemfile.rails-4.2.mongoid +6 -0
  26. data/gemfiles/Gemfile.rails-4.2.mongoid.kaminari +7 -0
  27. data/gemfiles/Gemfile.rails-4.2.mongoid.will_paginate +7 -0
  28. data/lib/chewy.rb +33 -5
  29. data/lib/chewy/config.rb +1 -0
  30. data/lib/chewy/index/search.rb +6 -3
  31. data/lib/chewy/query.rb +74 -1
  32. data/lib/chewy/query/compose.rb +4 -4
  33. data/lib/chewy/query/pagination.rb +5 -4
  34. data/lib/chewy/query/pagination/kaminari.rb +1 -1
  35. data/lib/chewy/query/pagination/will_paginate.rb +27 -0
  36. data/lib/chewy/type.rb +1 -0
  37. data/lib/chewy/type/adapter/active_record.rb +2 -2
  38. data/lib/chewy/type/adapter/mongoid.rb +147 -0
  39. data/lib/chewy/type/adapter/object.rb +1 -1
  40. data/lib/chewy/type/import.rb +1 -0
  41. data/lib/chewy/type/observe.rb +34 -6
  42. data/lib/chewy/version.rb +1 -1
  43. data/spec/chewy/config_spec.rb +17 -17
  44. data/spec/chewy/fields/base_spec.rb +62 -62
  45. data/spec/chewy/fields/root_spec.rb +5 -5
  46. data/spec/chewy/index/actions_spec.rb +127 -127
  47. data/spec/chewy/index/aliases_spec.rb +9 -9
  48. data/spec/chewy/index/search_spec.rb +4 -4
  49. data/spec/chewy/index/settings_spec.rb +33 -33
  50. data/spec/chewy/index_spec.rb +49 -49
  51. data/spec/chewy/query/criteria_spec.rb +173 -161
  52. data/spec/chewy/query/filters_spec.rb +76 -76
  53. data/spec/chewy/query/loading_spec.rb +54 -23
  54. data/spec/chewy/query/nodes/and_spec.rb +4 -4
  55. data/spec/chewy/query/nodes/bool_spec.rb +8 -8
  56. data/spec/chewy/query/nodes/equal_spec.rb +19 -19
  57. data/spec/chewy/query/nodes/exists_spec.rb +6 -6
  58. data/spec/chewy/query/nodes/has_child_spec.rb +25 -25
  59. data/spec/chewy/query/nodes/has_parent_spec.rb +25 -25
  60. data/spec/chewy/query/nodes/match_all_spec.rb +1 -1
  61. data/spec/chewy/query/nodes/missing_spec.rb +4 -4
  62. data/spec/chewy/query/nodes/not_spec.rb +4 -4
  63. data/spec/chewy/query/nodes/or_spec.rb +4 -4
  64. data/spec/chewy/query/nodes/prefix_spec.rb +5 -5
  65. data/spec/chewy/query/nodes/query_spec.rb +2 -2
  66. data/spec/chewy/query/nodes/range_spec.rb +18 -18
  67. data/spec/chewy/query/nodes/raw_spec.rb +1 -1
  68. data/spec/chewy/query/nodes/regexp_spec.rb +18 -18
  69. data/spec/chewy/query/nodes/script_spec.rb +4 -4
  70. data/spec/chewy/query/pagination/kaminari_spec.rb +41 -39
  71. data/spec/chewy/query/pagination/will_paginage_spec.rb +60 -0
  72. data/spec/chewy/query/pagination_spec.rb +8 -7
  73. data/spec/chewy/query_spec.rb +166 -167
  74. data/spec/chewy/rspec/update_index_spec.rb +1 -1
  75. data/spec/chewy/runtime/version_spec.rb +30 -30
  76. data/spec/chewy/runtime_spec.rb +3 -3
  77. data/spec/chewy/type/actions_spec.rb +3 -3
  78. data/spec/chewy/type/adapter/active_record_spec.rb +143 -143
  79. data/spec/chewy/type/adapter/mongoid_spec.rb +219 -0
  80. data/spec/chewy/type/adapter/object_spec.rb +39 -39
  81. data/spec/chewy/type/import_spec.rb +67 -37
  82. data/spec/chewy/type/mapping_spec.rb +12 -12
  83. data/spec/chewy/type/observe_spec.rb +5 -6
  84. data/spec/chewy/type/wrapper_spec.rb +12 -12
  85. data/spec/chewy_spec.rb +26 -28
  86. data/spec/spec_helper.rb +19 -31
  87. data/spec/support/active_record.rb +52 -0
  88. data/spec/support/class_helpers.rb +0 -4
  89. data/spec/support/mongoid.rb +87 -0
  90. metadata +33 -18
  91. data/gemfiles/Gemfile.rails-3.2 +0 -15
  92. data/gemfiles/Gemfile.rails-4.0 +0 -15
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Chewy::Fields::Root do
4
- specify { described_class.new('name').value.should be_a(Proc) }
4
+ specify { expect(described_class.new('name').value).to be_a(Proc) }
5
5
  # TODO: add 'should_behave_like base_field'
6
6
 
7
7
  subject(:field) { described_class.new('product') }
@@ -16,7 +16,7 @@ describe Chewy::Fields::Root do
16
16
  field.dynamic_template template_42: {mapping: {}, match: ''}
17
17
  field.dynamic_template /hello\..*/
18
18
 
19
- field.mappings_hash.should == {product: {dynamic_templates: [
19
+ expect(field.mappings_hash).to eq({product: {dynamic_templates: [
20
20
  {template_1: {mapping: {type: 'string'}, match: 'hello'}},
21
21
  {template_2: {mapping: {}, match_mapping_type: 'integer', match: 'hello*'}},
22
22
  {template_3: {mapping: {}, path_match: 'hello.*'}},
@@ -24,7 +24,7 @@ describe Chewy::Fields::Root do
24
24
  {template_5: {mapping: {}, match: 'hello.*', match_pattern: 'regexp'}},
25
25
  {template_42: {mapping: {}, match: ''}},
26
26
  {template_7: {mapping: {}, path_match: 'hello\..*', match_pattern: 'regexp'}}
27
- ]}}
27
+ ]}})
28
28
  end
29
29
 
30
30
  context do
@@ -34,10 +34,10 @@ describe Chewy::Fields::Root do
34
34
 
35
35
  specify do
36
36
  field.dynamic_template 'hello', type: 'string'
37
- field.mappings_hash.should == {product: {dynamic_templates: [
37
+ expect(field.mappings_hash).to eq({product: {dynamic_templates: [
38
38
  {template_42: {mapping: {}, match: ''}},
39
39
  {template_1: {mapping: {type: 'string'}, match: 'hello'}}
40
- ]}}
40
+ ]}})
41
41
  end
42
42
  end
43
43
  end
@@ -1,56 +1,56 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Chewy::Index::Actions do
4
- before { Chewy.client.indices.delete index: '*' }
4
+ before { Chewy.massacre }
5
5
 
6
6
  before { stub_index :dummies }
7
7
 
8
8
  describe '.exists?' do
9
- specify { DummiesIndex.exists?.should eq(false) }
9
+ specify { expect(DummiesIndex.exists?).to eq(false) }
10
10
 
11
11
  context do
12
12
  before { DummiesIndex.create }
13
- specify { DummiesIndex.exists?.should eq(true) }
13
+ specify { expect(DummiesIndex.exists?).to eq(true) }
14
14
  end
15
15
  end
16
16
 
17
17
  describe '.create' do
18
- specify { DummiesIndex.create["acknowledged"].should eq(true) }
19
- specify { DummiesIndex.create('2013')["acknowledged"].should eq(true) }
18
+ specify { expect(DummiesIndex.create["acknowledged"]).to eq(true) }
19
+ specify { expect(DummiesIndex.create('2013')["acknowledged"]).to eq(true) }
20
20
 
21
21
  context do
22
22
  before { DummiesIndex.create }
23
- specify { DummiesIndex.create.should eq(false) }
24
- specify { DummiesIndex.create('2013').should eq(false) }
23
+ specify { expect(DummiesIndex.create).to eq(false) }
24
+ specify { expect(DummiesIndex.create('2013')).to eq(false) }
25
25
  end
26
26
 
27
27
  context do
28
28
  before { DummiesIndex.create '2013' }
29
- specify { Chewy.client.indices.exists(index: 'dummies').should eq(true) }
30
- specify { Chewy.client.indices.exists(index: 'dummies_2013').should eq(true) }
31
- specify { DummiesIndex.aliases.should == [] }
32
- specify { DummiesIndex.indexes.should == ['dummies_2013'] }
33
- specify { DummiesIndex.create('2013').should eq(false) }
34
- specify { DummiesIndex.create('2014')["acknowledged"].should eq(true) }
29
+ specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(true) }
30
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(true) }
31
+ specify { expect(DummiesIndex.aliases).to eq([]) }
32
+ specify { expect(DummiesIndex.indexes).to eq(['dummies_2013']) }
33
+ specify { expect(DummiesIndex.create('2013')).to eq(false) }
34
+ specify { expect(DummiesIndex.create('2014')["acknowledged"]).to eq(true) }
35
35
 
36
36
  context do
37
37
  before { DummiesIndex.create '2014' }
38
- specify { DummiesIndex.indexes.should =~ ['dummies_2013', 'dummies_2014'] }
38
+ specify { expect(DummiesIndex.indexes).to match_array(['dummies_2013', 'dummies_2014']) }
39
39
  end
40
40
  end
41
41
 
42
42
  context do
43
43
  before { DummiesIndex.create '2013', alias: false }
44
- specify { Chewy.client.indices.exists(index: 'dummies').should eq(false) }
45
- specify { Chewy.client.indices.exists(index: 'dummies_2013').should eq(true) }
46
- specify { DummiesIndex.aliases.should == [] }
47
- specify { DummiesIndex.indexes.should == [] }
44
+ specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(false) }
45
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(true) }
46
+ specify { expect(DummiesIndex.aliases).to eq([]) }
47
+ specify { expect(DummiesIndex.indexes).to eq([]) }
48
48
  end
49
49
  end
50
50
 
51
51
  describe '.create!' do
52
- specify { DummiesIndex.create!["acknowledged"].should eq(true) }
53
- specify { DummiesIndex.create!('2013')["acknowledged"].should eq(true) }
52
+ specify { expect(DummiesIndex.create!["acknowledged"]).to eq(true) }
53
+ specify { expect(DummiesIndex.create!('2013')["acknowledged"]).to eq(true) }
54
54
 
55
55
  context do
56
56
  before { DummiesIndex.create }
@@ -60,68 +60,68 @@ describe Chewy::Index::Actions do
60
60
 
61
61
  context do
62
62
  before { DummiesIndex.create! '2013' }
63
- specify { Chewy.client.indices.exists(index: 'dummies').should eq(true) }
64
- specify { Chewy.client.indices.exists(index: 'dummies_2013').should eq(true) }
65
- specify { DummiesIndex.aliases.should == [] }
66
- specify { DummiesIndex.indexes.should == ['dummies_2013'] }
63
+ specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(true) }
64
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(true) }
65
+ specify { expect(DummiesIndex.aliases).to eq([]) }
66
+ specify { expect(DummiesIndex.indexes).to eq(['dummies_2013']) }
67
67
  specify { expect { DummiesIndex.create!('2013') }.to raise_error }
68
- specify { DummiesIndex.create!('2014')["acknowledged"].should eq(true) }
68
+ specify { expect(DummiesIndex.create!('2014')["acknowledged"]).to eq(true) }
69
69
 
70
70
  context do
71
71
  before { DummiesIndex.create! '2014' }
72
- specify { DummiesIndex.indexes.should =~ ['dummies_2013', 'dummies_2014'] }
72
+ specify { expect(DummiesIndex.indexes).to match_array(['dummies_2013', 'dummies_2014']) }
73
73
  end
74
74
  end
75
75
 
76
76
  context do
77
77
  before { DummiesIndex.create! '2013', alias: false }
78
- specify { Chewy.client.indices.exists(index: 'dummies').should eq(false) }
79
- specify { Chewy.client.indices.exists(index: 'dummies_2013').should eq(true) }
80
- specify { DummiesIndex.aliases.should == [] }
81
- specify { DummiesIndex.indexes.should == [] }
78
+ specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(false) }
79
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(true) }
80
+ specify { expect(DummiesIndex.aliases).to eq([]) }
81
+ specify { expect(DummiesIndex.indexes).to eq([]) }
82
82
  end
83
83
  end
84
84
 
85
85
  describe '.delete' do
86
- specify { DummiesIndex.delete.should eq(false) }
87
- specify { DummiesIndex.delete('dummies_2013').should eq(false) }
86
+ specify { expect(DummiesIndex.delete).to eq(false) }
87
+ specify { expect(DummiesIndex.delete('dummies_2013')).to eq(false) }
88
88
 
89
89
  context do
90
90
  before { DummiesIndex.create }
91
- specify { DummiesIndex.delete["acknowledged"].should eq(true) }
91
+ specify { expect(DummiesIndex.delete["acknowledged"]).to eq(true) }
92
92
 
93
93
  context do
94
94
  before { DummiesIndex.delete }
95
- specify { Chewy.client.indices.exists(index: 'dummies').should eq(false) }
95
+ specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(false) }
96
96
  end
97
97
  end
98
98
 
99
99
  context do
100
100
  before { DummiesIndex.create '2013' }
101
- specify { DummiesIndex.delete('2013')["acknowledged"].should eq(true) }
101
+ specify { expect(DummiesIndex.delete('2013')["acknowledged"]).to eq(true) }
102
102
 
103
103
  context do
104
104
  before { DummiesIndex.delete('2013') }
105
- specify { Chewy.client.indices.exists(index: 'dummies').should eq(false) }
106
- specify { Chewy.client.indices.exists(index: 'dummies_2013').should eq(false) }
105
+ specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(false) }
106
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(false) }
107
107
  end
108
108
 
109
109
  context do
110
110
  before { DummiesIndex.create '2014' }
111
- specify { DummiesIndex.delete["acknowledged"].should eq(true) }
111
+ specify { expect(DummiesIndex.delete["acknowledged"]).to eq(true) }
112
112
 
113
113
  context do
114
114
  before { DummiesIndex.delete }
115
- specify { Chewy.client.indices.exists(index: 'dummies').should eq(false) }
116
- specify { Chewy.client.indices.exists(index: 'dummies_2013').should eq(false) }
117
- specify { Chewy.client.indices.exists(index: 'dummies_2014').should eq(false) }
115
+ specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(false) }
116
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(false) }
117
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_2014')).to eq(false) }
118
118
  end
119
119
 
120
120
  context do
121
121
  before { DummiesIndex.delete('2014') }
122
- specify { Chewy.client.indices.exists(index: 'dummies').should eq(true) }
123
- specify { Chewy.client.indices.exists(index: 'dummies_2013').should eq(true) }
124
- specify { Chewy.client.indices.exists(index: 'dummies_2014').should eq(false) }
122
+ specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(true) }
123
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(true) }
124
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_2014')).to eq(false) }
125
125
  end
126
126
  end
127
127
  end
@@ -133,149 +133,149 @@ describe Chewy::Index::Actions do
133
133
 
134
134
  context do
135
135
  before { DummiesIndex.create }
136
- specify { DummiesIndex.delete!["acknowledged"].should eq(true) }
136
+ specify { expect(DummiesIndex.delete!["acknowledged"]).to eq(true) }
137
137
 
138
138
  context do
139
139
  before { DummiesIndex.delete! }
140
- specify { Chewy.client.indices.exists(index: 'dummies').should eq(false) }
140
+ specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(false) }
141
141
  end
142
142
  end
143
143
 
144
144
  context do
145
145
  before { DummiesIndex.create '2013' }
146
- specify { DummiesIndex.delete!('2013')["acknowledged"].should eq(true) }
146
+ specify { expect(DummiesIndex.delete!('2013')["acknowledged"]).to eq(true) }
147
147
 
148
148
  context do
149
149
  before { DummiesIndex.delete!('2013') }
150
- specify { Chewy.client.indices.exists(index: 'dummies').should eq(false) }
151
- specify { Chewy.client.indices.exists(index: 'dummies_2013').should eq(false) }
150
+ specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(false) }
151
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(false) }
152
152
  end
153
153
 
154
154
  context do
155
155
  before { DummiesIndex.create '2014' }
156
- specify { DummiesIndex.delete!["acknowledged"].should eq(true) }
156
+ specify { expect(DummiesIndex.delete!["acknowledged"]).to eq(true) }
157
157
 
158
158
  context do
159
159
  before { DummiesIndex.delete! }
160
- specify { Chewy.client.indices.exists(index: 'dummies').should eq(false) }
161
- specify { Chewy.client.indices.exists(index: 'dummies_2013').should eq(false) }
162
- specify { Chewy.client.indices.exists(index: 'dummies_2014').should eq(false) }
160
+ specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(false) }
161
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(false) }
162
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_2014')).to eq(false) }
163
163
  end
164
164
 
165
165
  context do
166
166
  before { DummiesIndex.delete!('2014') }
167
- specify { Chewy.client.indices.exists(index: 'dummies').should eq(true) }
168
- specify { Chewy.client.indices.exists(index: 'dummies_2013').should eq(true) }
169
- specify { Chewy.client.indices.exists(index: 'dummies_2014').should eq(false) }
167
+ specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(true) }
168
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(true) }
169
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_2014')).to eq(false) }
170
170
  end
171
171
  end
172
172
  end
173
173
  end
174
174
 
175
175
  describe '.purge' do
176
- specify { DummiesIndex.purge["acknowledged"].should eq(true) }
177
- specify { DummiesIndex.purge('2013')["acknowledged"].should eq(true) }
176
+ specify { expect(DummiesIndex.purge["acknowledged"]).to eq(true) }
177
+ specify { expect(DummiesIndex.purge('2013')["acknowledged"]).to eq(true) }
178
178
 
179
179
  context do
180
180
  before { DummiesIndex.purge }
181
- specify { DummiesIndex.should be_exists }
182
- specify { DummiesIndex.aliases.should == [] }
183
- specify { DummiesIndex.indexes.should == [] }
181
+ specify { expect(DummiesIndex).to be_exists }
182
+ specify { expect(DummiesIndex.aliases).to eq([]) }
183
+ specify { expect(DummiesIndex.indexes).to eq([]) }
184
184
 
185
185
  context do
186
186
  before { DummiesIndex.purge }
187
- specify { DummiesIndex.should be_exists }
188
- specify { DummiesIndex.aliases.should == [] }
189
- specify { DummiesIndex.indexes.should == [] }
187
+ specify { expect(DummiesIndex).to be_exists }
188
+ specify { expect(DummiesIndex.aliases).to eq([]) }
189
+ specify { expect(DummiesIndex.indexes).to eq([]) }
190
190
  end
191
191
 
192
192
  context do
193
193
  before { DummiesIndex.purge('2013') }
194
- specify { DummiesIndex.should be_exists }
195
- specify { DummiesIndex.aliases.should == [] }
196
- specify { DummiesIndex.indexes.should == ['dummies_2013'] }
194
+ specify { expect(DummiesIndex).to be_exists }
195
+ specify { expect(DummiesIndex.aliases).to eq([]) }
196
+ specify { expect(DummiesIndex.indexes).to eq(['dummies_2013']) }
197
197
  end
198
198
  end
199
199
 
200
200
  context do
201
201
  before { DummiesIndex.purge('2013') }
202
- specify { DummiesIndex.should be_exists }
203
- specify { DummiesIndex.aliases.should == [] }
204
- specify { DummiesIndex.indexes.should == ['dummies_2013'] }
202
+ specify { expect(DummiesIndex).to be_exists }
203
+ specify { expect(DummiesIndex.aliases).to eq([]) }
204
+ specify { expect(DummiesIndex.indexes).to eq(['dummies_2013']) }
205
205
 
206
206
  context do
207
207
  before { DummiesIndex.purge }
208
- specify { DummiesIndex.should be_exists }
209
- specify { DummiesIndex.aliases.should == [] }
210
- specify { DummiesIndex.indexes.should == [] }
208
+ specify { expect(DummiesIndex).to be_exists }
209
+ specify { expect(DummiesIndex.aliases).to eq([]) }
210
+ specify { expect(DummiesIndex.indexes).to eq([]) }
211
211
  end
212
212
 
213
213
  context do
214
214
  before { DummiesIndex.purge('2014') }
215
- specify { DummiesIndex.should be_exists }
216
- specify { DummiesIndex.aliases.should == [] }
217
- specify { DummiesIndex.indexes.should == ['dummies_2014'] }
215
+ specify { expect(DummiesIndex).to be_exists }
216
+ specify { expect(DummiesIndex.aliases).to eq([]) }
217
+ specify { expect(DummiesIndex.indexes).to eq(['dummies_2014']) }
218
218
  end
219
219
  end
220
220
  end
221
221
 
222
222
  describe '.purge!' do
223
- specify { DummiesIndex.purge!["acknowledged"].should eq(true) }
224
- specify { DummiesIndex.purge!('2013')["acknowledged"].should eq(true) }
223
+ specify { expect(DummiesIndex.purge!["acknowledged"]).to eq(true) }
224
+ specify { expect(DummiesIndex.purge!('2013')["acknowledged"]).to eq(true) }
225
225
 
226
226
  context do
227
227
  before { DummiesIndex.purge! }
228
- specify { DummiesIndex.should be_exists }
229
- specify { DummiesIndex.aliases.should == [] }
230
- specify { DummiesIndex.indexes.should == [] }
228
+ specify { expect(DummiesIndex).to be_exists }
229
+ specify { expect(DummiesIndex.aliases).to eq([]) }
230
+ specify { expect(DummiesIndex.indexes).to eq([]) }
231
231
 
232
232
  context do
233
233
  before { DummiesIndex.purge! }
234
- specify { DummiesIndex.should be_exists }
235
- specify { DummiesIndex.aliases.should == [] }
236
- specify { DummiesIndex.indexes.should == [] }
234
+ specify { expect(DummiesIndex).to be_exists }
235
+ specify { expect(DummiesIndex.aliases).to eq([]) }
236
+ specify { expect(DummiesIndex.indexes).to eq([]) }
237
237
  end
238
238
 
239
239
  context do
240
240
  before { DummiesIndex.purge!('2013') }
241
- specify { DummiesIndex.should be_exists }
242
- specify { DummiesIndex.aliases.should == [] }
243
- specify { DummiesIndex.indexes.should == ['dummies_2013'] }
241
+ specify { expect(DummiesIndex).to be_exists }
242
+ specify { expect(DummiesIndex.aliases).to eq([]) }
243
+ specify { expect(DummiesIndex.indexes).to eq(['dummies_2013']) }
244
244
  end
245
245
  end
246
246
 
247
247
  context do
248
248
  before { DummiesIndex.purge!('2013') }
249
- specify { DummiesIndex.should be_exists }
250
- specify { DummiesIndex.aliases.should == [] }
251
- specify { DummiesIndex.indexes.should == ['dummies_2013'] }
249
+ specify { expect(DummiesIndex).to be_exists }
250
+ specify { expect(DummiesIndex.aliases).to eq([]) }
251
+ specify { expect(DummiesIndex.indexes).to eq(['dummies_2013']) }
252
252
 
253
253
  context do
254
254
  before { DummiesIndex.purge! }
255
- specify { DummiesIndex.should be_exists }
256
- specify { DummiesIndex.aliases.should == [] }
257
- specify { DummiesIndex.indexes.should == [] }
255
+ specify { expect(DummiesIndex).to be_exists }
256
+ specify { expect(DummiesIndex.aliases).to eq([]) }
257
+ specify { expect(DummiesIndex.indexes).to eq([]) }
258
258
  end
259
259
 
260
260
  context do
261
261
  before { DummiesIndex.purge!('2014') }
262
- specify { DummiesIndex.should be_exists }
263
- specify { DummiesIndex.aliases.should == [] }
264
- specify { DummiesIndex.indexes.should == ['dummies_2014'] }
262
+ specify { expect(DummiesIndex).to be_exists }
263
+ specify { expect(DummiesIndex.aliases).to eq([]) }
264
+ specify { expect(DummiesIndex.indexes).to eq(['dummies_2014']) }
265
265
  end
266
266
  end
267
267
  end
268
268
 
269
- describe '.import' do
269
+ describe '.import', :orm do
270
270
  before do
271
271
  stub_model(:city)
272
272
  stub_index(:cities) do
273
273
  define_type City
274
274
  end
275
275
  end
276
- let!(:dummy_cities) { 3.times.map { |i| City.create(name: "name#{i}") } }
276
+ let!(:dummy_cities) { 3.times.map { |i| City.create(id: i + 1, name: "name#{i}") } }
277
277
 
278
- specify { CitiesIndex.import.should == true }
278
+ specify { expect(CitiesIndex.import).to eq(true) }
279
279
 
280
280
  context do
281
281
  before do
@@ -286,20 +286,20 @@ describe Chewy::Index::Actions do
286
286
  end
287
287
  end
288
288
 
289
- specify { CitiesIndex.import(city: dummy_cities).should == false }
289
+ specify { expect(CitiesIndex.import(city: dummy_cities)).to eq(false) }
290
290
  end
291
291
  end
292
292
 
293
- describe '.import!' do
293
+ describe '.import!', :orm do
294
294
  before do
295
295
  stub_model(:city)
296
296
  stub_index(:cities) do
297
297
  define_type City
298
298
  end
299
299
  end
300
- let!(:dummy_cities) { 3.times.map { |i| City.create(name: "name#{i}") } }
300
+ let!(:dummy_cities) { 3.times.map { |i| City.create(id: i + 1, name: "name#{i}") } }
301
301
 
302
- specify { CitiesIndex.import!.should == true }
302
+ specify { expect(CitiesIndex.import!).to eq(true) }
303
303
 
304
304
  context do
305
305
  before do
@@ -314,7 +314,7 @@ describe Chewy::Index::Actions do
314
314
  end
315
315
  end
316
316
 
317
- describe '.reset!' do
317
+ describe '.reset!', :orm do
318
318
  before do
319
319
  stub_model(:city)
320
320
  stub_index(:cities) do
@@ -322,58 +322,58 @@ describe Chewy::Index::Actions do
322
322
  end
323
323
  end
324
324
 
325
- before { City.create!(name: 'Moscow') }
325
+ before { City.create!(id: 1, name: 'Moscow') }
326
326
 
327
- specify { CitiesIndex.reset!.should eq(true) }
328
- specify { CitiesIndex.reset!('2013').should eq(true) }
327
+ specify { expect(CitiesIndex.reset!).to eq(true) }
328
+ specify { expect(CitiesIndex.reset!('2013')).to eq(true) }
329
329
 
330
330
  context do
331
331
  before { CitiesIndex.reset! }
332
332
 
333
- specify { CitiesIndex.all.should have(1).item }
334
- specify { CitiesIndex.aliases.should == [] }
335
- specify { CitiesIndex.indexes.should == [] }
333
+ specify { expect(CitiesIndex.all).to have(1).item }
334
+ specify { expect(CitiesIndex.aliases).to eq([]) }
335
+ specify { expect(CitiesIndex.indexes).to eq([]) }
336
336
 
337
337
  context do
338
338
  before { CitiesIndex.reset!('2013') }
339
339
 
340
- specify { CitiesIndex.all.should have(1).item }
341
- specify { CitiesIndex.aliases.should == [] }
342
- specify { CitiesIndex.indexes.should == ['cities_2013'] }
340
+ specify { expect(CitiesIndex.all).to have(1).item }
341
+ specify { expect(CitiesIndex.aliases).to eq([]) }
342
+ specify { expect(CitiesIndex.indexes).to eq(['cities_2013']) }
343
343
  end
344
344
 
345
345
  context do
346
346
  before { CitiesIndex.reset! }
347
347
 
348
- specify { CitiesIndex.all.should have(1).item }
349
- specify { CitiesIndex.aliases.should == [] }
350
- specify { CitiesIndex.indexes.should == [] }
348
+ specify { expect(CitiesIndex.all).to have(1).item }
349
+ specify { expect(CitiesIndex.aliases).to eq([]) }
350
+ specify { expect(CitiesIndex.indexes).to eq([]) }
351
351
  end
352
352
  end
353
353
 
354
354
  context do
355
355
  before { CitiesIndex.reset!('2013') }
356
356
 
357
- specify { CitiesIndex.all.should have(1).item }
358
- specify { CitiesIndex.aliases.should == [] }
359
- specify { CitiesIndex.indexes.should == ['cities_2013'] }
357
+ specify { expect(CitiesIndex.all).to have(1).item }
358
+ specify { expect(CitiesIndex.aliases).to eq([]) }
359
+ specify { expect(CitiesIndex.indexes).to eq(['cities_2013']) }
360
360
 
361
361
  context do
362
362
  before { CitiesIndex.reset!('2014') }
363
363
 
364
- specify { CitiesIndex.all.should have(1).item }
365
- specify { CitiesIndex.aliases.should == [] }
366
- specify { CitiesIndex.indexes.should == ['cities_2014'] }
367
- specify { Chewy.client.indices.exists(index: 'cities_2013').should eq(false) }
364
+ specify { expect(CitiesIndex.all).to have(1).item }
365
+ specify { expect(CitiesIndex.aliases).to eq([]) }
366
+ specify { expect(CitiesIndex.indexes).to eq(['cities_2014']) }
367
+ specify { expect(Chewy.client.indices.exists(index: 'cities_2013')).to eq(false) }
368
368
  end
369
369
 
370
370
  context do
371
371
  before { CitiesIndex.reset! }
372
372
 
373
- specify { CitiesIndex.all.should have(1).item }
374
- specify { CitiesIndex.aliases.should == [] }
375
- specify { CitiesIndex.indexes.should == [] }
376
- specify { Chewy.client.indices.exists(index: 'cities_2013').should eq(false) }
373
+ specify { expect(CitiesIndex.all).to have(1).item }
374
+ specify { expect(CitiesIndex.aliases).to eq([]) }
375
+ specify { expect(CitiesIndex.indexes).to eq([]) }
376
+ specify { expect(Chewy.client.indices.exists(index: 'cities_2013')).to eq(false) }
377
377
  end
378
378
  end
379
379
  end