picky 4.19.4 → 4.19.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/lib/picky/categories.rb +1 -0
  3. data/lib/picky/category_realtime.rb +1 -1
  4. data/lib/picky/index.rb +7 -1
  5. data/lib/picky/query/indexes/check.rb +2 -0
  6. data/lib/picky/query/or.rb +0 -13
  7. data/lib/picky/results.rb +4 -2
  8. data/lib/picky/search.rb +6 -8
  9. data/lib/picky/search_facets.rb +1 -1
  10. data/lib/picky.rb +5 -2
  11. data/spec/functional/or_spec.rb +1 -0
  12. data/spec/functional/to_s_spec.rb +57 -0
  13. data/spec/lib/api/search/boost_spec.rb +1 -1
  14. data/spec/lib/backends/backend_spec.rb +2 -2
  15. data/spec/lib/backends/file_spec.rb +25 -25
  16. data/spec/lib/backends/memory/json_spec.rb +1 -1
  17. data/spec/lib/backends/memory/marshal_spec.rb +1 -1
  18. data/spec/lib/backends/memory_spec.rb +28 -28
  19. data/spec/lib/backends/prepared/text_spec.rb +3 -3
  20. data/spec/lib/backends/redis/basic_spec.rb +1 -1
  21. data/spec/lib/backends/redis/directly_manipulable_spec.rb +8 -8
  22. data/spec/lib/backends/redis/float_spec.rb +3 -3
  23. data/spec/lib/backends/redis/list_spec.rb +2 -2
  24. data/spec/lib/backends/redis/string_spec.rb +2 -2
  25. data/spec/lib/backends/redis_spec.rb +33 -33
  26. data/spec/lib/backends/sqlite/array_spec.rb +12 -12
  27. data/spec/lib/backends/sqlite/directly_manipulable_spec.rb +4 -4
  28. data/spec/lib/backends/sqlite/value_spec.rb +8 -8
  29. data/spec/lib/backends/sqlite_spec.rb +28 -28
  30. data/spec/lib/bundle_indexed_spec.rb +14 -14
  31. data/spec/lib/categories_indexed_spec.rb +12 -12
  32. data/spec/lib/category_indexed_spec.rb +27 -27
  33. data/spec/lib/category_indexing_spec.rb +18 -18
  34. data/spec/lib/extensions/module_spec.rb +2 -2
  35. data/spec/lib/extensions/object_spec.rb +1 -1
  36. data/spec/lib/generators/partial/default_spec.rb +1 -1
  37. data/spec/lib/generators/partial/postfix_spec.rb +2 -2
  38. data/spec/lib/generators/similarity/phonetic_spec.rb +1 -1
  39. data/spec/lib/index_indexed_spec.rb +3 -3
  40. data/spec/lib/index_indexing_spec.rb +5 -5
  41. data/spec/lib/index_spec.rb +3 -3
  42. data/spec/lib/indexed/wrappers/bundle/calculation_spec.rb +1 -1
  43. data/spec/lib/indexed/wrappers/bundle/wrapper_spec.rb +1 -1
  44. data/spec/lib/indexers/base_spec.rb +8 -8
  45. data/spec/lib/indexers/parallel_spec.rb +6 -6
  46. data/spec/lib/indexers/serial_spec.rb +4 -4
  47. data/spec/lib/indexes_class_spec.rb +1 -1
  48. data/spec/lib/indexes_indexed_spec.rb +4 -4
  49. data/spec/lib/indexes_indexing_spec.rb +5 -5
  50. data/spec/lib/indexes_spec.rb +2 -2
  51. data/spec/lib/interfaces/live_parameters/master_child_spec.rb +13 -13
  52. data/spec/lib/interfaces/live_parameters/unicorn_spec.rb +13 -13
  53. data/spec/lib/loader_spec.rb +9 -9
  54. data/spec/lib/loggers/verbose_spec.rb +10 -3
  55. data/spec/lib/query/allocation_spec.rb +22 -22
  56. data/spec/lib/query/allocations_spec.rb +32 -32
  57. data/spec/lib/query/boosts_spec.rb +2 -2
  58. data/spec/lib/query/combination_spec.rb +5 -5
  59. data/spec/lib/query/combinations_spec.rb +8 -8
  60. data/spec/lib/query/indexes_check_spec.rb +6 -6
  61. data/spec/lib/query/indexes_spec.rb +8 -8
  62. data/spec/lib/query/solr_spec.rb +5 -5
  63. data/spec/lib/query/token_spec.rb +6 -6
  64. data/spec/lib/query/tokens_spec.rb +10 -10
  65. data/spec/lib/rack/harakiri_spec.rb +5 -5
  66. data/spec/lib/results/exact_first_spec.rb +23 -23
  67. data/spec/lib/results_spec.rb +10 -10
  68. data/spec/lib/scheduler_spec.rb +5 -5
  69. data/spec/lib/search_spec.rb +15 -15
  70. data/spec/lib/solr/schema_generator_spec.rb +7 -7
  71. data/spec/lib/tokenizer_spec.rb +3 -3
  72. metadata +48 -104
@@ -6,19 +6,19 @@ describe Picky::Category do
6
6
  @index = Picky::Index.new :some_index do
7
7
  source []
8
8
  end
9
- @partial_strategy = stub :partial, :each_partial => nil, :use_exact_for_partial? => false
10
- @weight_strategy = stub :weights, :saved? => true, :weight_for => :some_weight
11
- @similarity_strategy = stub :similarity, :encode => nil, :prioritize => nil
9
+ @partial_strategy = double :partial, :each_partial => nil, :use_exact_for_partial? => false
10
+ @weight_strategy = double :weights, :saved? => true, :weight_for => :some_weight
11
+ @similarity_strategy = double :similarity, :encode => nil, :prioritize => nil
12
12
 
13
- @exact = stub :exact, :dump => nil
14
- @partial = stub :partial, :dump => nil
13
+ @exact = double :exact, :dump => nil
14
+ @partial = double :partial, :dump => nil
15
15
 
16
16
  @category = described_class.new :some_name, @index, :partial => @partial_strategy,
17
17
  :weight => @weight_strategy,
18
18
  :similarity => @similarity_strategy,
19
19
  :qualifiers => [:q, :qualifier]
20
20
 
21
- @category.stub! :exclaim
21
+ @category.stub :exclaim
22
22
  end
23
23
 
24
24
  describe 'partial' do
@@ -28,7 +28,7 @@ describe Picky::Category do
28
28
  end
29
29
  context 'with a partial strategy that uses the exact index' do
30
30
  before(:each) do
31
- @partial_strategy.stub! :use_exact_for_partial? => true
31
+ @partial_strategy.stub :use_exact_for_partial? => true
32
32
  end
33
33
  it 'returns the partial index' do
34
34
  @category.partial.should be_kind_of(Picky::Bundle)
@@ -49,7 +49,7 @@ describe Picky::Category do
49
49
  end
50
50
  context 'with a partial strategy that uses the exact index' do
51
51
  before(:each) do
52
- @partial_strategy.stub! :use_exact_for_partial? => true
52
+ @partial_strategy.stub :use_exact_for_partial? => true
53
53
  end
54
54
  it 'returns the partial index' do
55
55
  @category.partial.should be_kind_of(Picky::Bundle)
@@ -64,14 +64,14 @@ describe Picky::Category do
64
64
  end
65
65
 
66
66
  describe 'weight' do
67
- let(:token) { stub :token, :text => :some_text }
67
+ let(:token) { double :token, :text => :some_text }
68
68
  context 'without range' do
69
69
  before :each do
70
- token.stub! :range => nil
70
+ token.stub :range => nil
71
71
  end
72
72
  context 'partial bundle' do
73
73
  before(:each) do
74
- @category.stub! :bundle_for => @partial
74
+ @category.stub :bundle_for => @partial
75
75
  end
76
76
  it 'should receive weight with the token text' do
77
77
  @partial.should_receive(:weight).once.with :some_text
@@ -81,7 +81,7 @@ describe Picky::Category do
81
81
  end
82
82
  context 'exact bundle' do
83
83
  before(:each) do
84
- @category.stub! :bundle_for => @exact
84
+ @category.stub :bundle_for => @exact
85
85
  end
86
86
  it 'should receive weight with the token text' do
87
87
  @exact.should_receive(:weight).once.with :some_text
@@ -92,11 +92,11 @@ describe Picky::Category do
92
92
  end
93
93
  context 'with range' do
94
94
  before :each do
95
- token.stub! :range => [1, 3]
95
+ token.stub :range => [1, 3]
96
96
  end
97
97
  context 'partial bundle' do
98
98
  before(:each) do
99
- @category.stub! :bundle_for => @partial
99
+ @category.stub :bundle_for => @partial
100
100
  end
101
101
  it 'should receive weight with the token text' do
102
102
  @partial.should_receive(:weight).once.times.with(1).and_return(1)
@@ -115,7 +115,7 @@ describe Picky::Category do
115
115
  end
116
116
  context 'exact bundle' do
117
117
  before(:each) do
118
- @category.stub! :bundle_for => @exact
118
+ @category.stub :bundle_for => @exact
119
119
  end
120
120
  it 'should receive weight with the token text' do
121
121
  @exact.should_receive(:weight).once.times.with(1).and_return(1)
@@ -129,12 +129,12 @@ describe Picky::Category do
129
129
  end
130
130
 
131
131
  describe 'ids' do
132
- let(:token) { stub :token, :text => :some_text }
132
+ let(:token) { double :token, :text => :some_text }
133
133
  context 'without range' do
134
- before(:each) { token.stub! :range => nil }
134
+ before(:each) { token.stub :range => nil }
135
135
  context 'partial bundle' do
136
136
  before(:each) do
137
- @category.stub! :bundle_for => @partial
137
+ @category.stub :bundle_for => @partial
138
138
  end
139
139
  it 'should receive ids with the token text' do
140
140
  @partial.should_receive(:ids).once.with :some_text
@@ -144,7 +144,7 @@ describe Picky::Category do
144
144
  end
145
145
  context 'exact bundle' do
146
146
  before(:each) do
147
- @category.stub! :bundle_for => @exact
147
+ @category.stub :bundle_for => @exact
148
148
  end
149
149
  it 'should receive ids with the token text' do
150
150
  @exact.should_receive(:ids).once.with :some_text
@@ -154,10 +154,10 @@ describe Picky::Category do
154
154
  end
155
155
  end
156
156
  context 'with range' do
157
- before(:each) { token.stub! :range => [1, 3] }
157
+ before(:each) { token.stub :range => [1, 3] }
158
158
  context 'partial bundle' do
159
159
  before(:each) do
160
- @category.stub! :bundle_for => @partial
160
+ @category.stub :bundle_for => @partial
161
161
  end
162
162
  it 'should receive ids with the token text' do
163
163
  @partial.should_receive(:ids).once.with(1).and_return [1]
@@ -169,7 +169,7 @@ describe Picky::Category do
169
169
  end
170
170
  context 'exact bundle' do
171
171
  before(:each) do
172
- @category.stub! :bundle_for => @exact
172
+ @category.stub :bundle_for => @exact
173
173
  end
174
174
  it 'should receive ids with the token text' do
175
175
  @exact.should_receive(:ids).once.with(1).and_return [1]
@@ -185,7 +185,7 @@ describe Picky::Category do
185
185
  # describe 'combination_for' do
186
186
  # context 'no weight for token' do
187
187
  # before(:each) do
188
- # @category.stub! :weight => nil
188
+ # @category.stub :weight => nil
189
189
  # end
190
190
  # it 'should return nil' do
191
191
  # @category.combination_for(:anything).should == nil
@@ -193,8 +193,8 @@ describe Picky::Category do
193
193
  # end
194
194
  # context 'weight for token' do
195
195
  # before(:each) do
196
- # @token = stub :token, :text => :some_text
197
- # @category.stub! :weight => :some_weight, :bundle_for => :bundle
196
+ # @token = double :token, :text => :some_text
197
+ # @category.stub :weight => :some_weight, :bundle_for => :bundle
198
198
  # end
199
199
  # it 'should return a new combination' do
200
200
  # @category.combination_for(@token).should be_kind_of(Picky::Query::Combination)
@@ -209,8 +209,8 @@ describe Picky::Category do
209
209
 
210
210
  context 'stubbed exact/partial' do
211
211
  before(:each) do
212
- @category.stub! :exact => (@exact = stub :exact)
213
- @category.stub! :partial => (@partial = stub :partial)
212
+ @category.stub :exact => (@exact = double :exact)
213
+ @category.stub :partial => (@partial = double :partial)
214
214
  end
215
215
 
216
216
  describe 'load' do
@@ -4,9 +4,9 @@ describe Picky::Category do
4
4
 
5
5
  before(:each) do
6
6
  @index = Picky::Index.new :some_index
7
- @source = stub :some_given_source, :each => nil
7
+ @source = double :some_given_source, :each => nil
8
8
  end
9
- let(:category) { described_class.new(:some_category, @index, :source => @source).tap { |c| c.stub! :timed_exclaim } }
9
+ let(:category) { described_class.new(:some_category, @index, :source => @source).tap { |c| c.stub :timed_exclaim } }
10
10
 
11
11
  context "unit specs" do
12
12
  let(:exact) { category.exact }
@@ -14,8 +14,8 @@ describe Picky::Category do
14
14
 
15
15
  describe 'clear' do
16
16
  it 'forwards to both bundles' do
17
- exact.should_receive(:clear).once.with()
18
- partial.should_receive(:clear).once.with()
17
+ exact.should_receive(:clear).once.with no_args
18
+ partial.should_receive(:clear).once.with no_args
19
19
 
20
20
  category.clear
21
21
  end
@@ -23,16 +23,16 @@ describe Picky::Category do
23
23
 
24
24
  describe 'dump' do
25
25
  before(:each) do
26
- exact.stub! :dump
27
- partial.stub! :dump
26
+ exact.stub :dump
27
+ partial.stub :dump
28
28
  end
29
29
  it 'should dump the exact index' do
30
- exact.should_receive(:dump).once.with
30
+ exact.should_receive(:dump).once.with no_args
31
31
 
32
32
  category.dump
33
33
  end
34
34
  it 'should dump the partial index' do
35
- partial.should_receive(:dump).once.with
35
+ partial.should_receive(:dump).once.with no_args
36
36
 
37
37
  category.dump
38
38
  end
@@ -40,9 +40,9 @@ describe Picky::Category do
40
40
 
41
41
  describe 'cache' do
42
42
  it 'should call multiple methods in order' do
43
- category.should_receive(:empty).once.with().ordered
44
- category.should_receive(:retrieve).once.with().ordered
45
- category.should_receive(:dump).once.with().ordered
43
+ category.should_receive(:empty).once.with(no_args).ordered
44
+ category.should_receive(:retrieve).once.with(no_args).ordered
45
+ category.should_receive(:dump).once.with(no_args).ordered
46
46
 
47
47
  category.cache
48
48
  end
@@ -50,14 +50,14 @@ describe Picky::Category do
50
50
 
51
51
  describe 'retrieve' do
52
52
  it 'call the right thing' do
53
- prepared = stub :prepared
54
- prepared.should_receive(:retrieve).any_number_of_times
53
+ prepared = double :prepared
54
+ prepared.should_receive(:retrieve).at_least(1)
55
55
  .and_yield(1, :some_token)
56
56
  .and_yield(2, :some_token)
57
57
  .and_yield(3, :some_token)
58
58
  .and_yield(4, :some_token)
59
59
  .and_yield(5, :some_token)
60
- category.stub! :prepared => prepared
60
+ category.stub :prepared => prepared
61
61
 
62
62
  category.should_receive(:add_tokenized_token).once.with(1, :some_token, :<<, nil)
63
63
  category.should_receive(:add_tokenized_token).once.with(2, :some_token, :<<, nil)
@@ -84,7 +84,7 @@ describe Picky::Category do
84
84
  end
85
85
  context 'it has an index' do
86
86
  before(:each) do
87
- category.instance_variable_set :@index, stub(:index, :key_format => :yet_another_key_format)
87
+ category.instance_variable_set :@index, double(:index, :key_format => :yet_another_key_format)
88
88
  end
89
89
  it 'returns that key_format' do
90
90
  category.key_format.should == :yet_another_key_format
@@ -101,7 +101,7 @@ describe Picky::Category do
101
101
  end
102
102
  end
103
103
  context 'without explicit source' do
104
- let(:category) { described_class.new(:some_category, @index.tap{ |index| index.stub! :source => :index_source }) }
104
+ let(:category) { described_class.new(:some_category, @index.tap{ |index| index.stub :source => :index_source }) }
105
105
  it 'returns the right source' do
106
106
  category.source.should == :index_source
107
107
  end
@@ -110,8 +110,8 @@ describe Picky::Category do
110
110
 
111
111
  describe "index" do
112
112
  before(:each) do
113
- @indexer = stub :indexer, :index => nil
114
- category.stub! :indexer => @indexer
113
+ @indexer = double :indexer, :index => nil
114
+ category.stub :indexer => @indexer
115
115
  end
116
116
  it "tells the indexer to index" do
117
117
  @indexer.should_receive(:prepare).once
@@ -16,7 +16,7 @@ describe Module do
16
16
  end
17
17
  end
18
18
  it 'should send each a bli' do
19
- bli = stub :bli
19
+ bli = double :bli
20
20
  delegating = klass.new [bli, bli, bli, bli]
21
21
 
22
22
  bli.should_receive(:bli).exactly(4).times
@@ -49,7 +49,7 @@ describe Module do
49
49
  end
50
50
  end
51
51
  it 'should send each a bli' do
52
- bli = stub :bli
52
+ bli = double :bli
53
53
  delegating = klass.new bli
54
54
 
55
55
  bli.should_receive(:bli).exactly(1).times
@@ -9,7 +9,7 @@ describe Object do
9
9
 
10
10
  describe "timed_exclaim" do
11
11
  it "should exclaim right" do
12
- Time.stub! :now => Time.parse('07-03-1977 12:34:56')
12
+ Time.stub :now => Time.parse('07-03-1977 12:34:56')
13
13
  object.should_receive(:exclaim).once.with "12:34:56: bla"
14
14
 
15
15
  object.timed_exclaim 'bla'
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Picky::Generators::Partial::Default do
3
+ describe 'Picky::Generators::Partial::Default' do
4
4
 
5
5
  let(:default) { Picky::Generators::Partial::Default }
6
6
 
@@ -6,8 +6,8 @@ describe Picky::Generators::Partial::Postfix do
6
6
  let(:generator) { described_class.new }
7
7
 
8
8
  describe 'use_exact_for_partial?' do
9
- it 'returns false' do
10
- described_class.new.use_exact_for_partial?.should == false
9
+ it 'is correct' do
10
+ generator.use_exact_for_partial?.should be_falsy
11
11
  end
12
12
  end
13
13
  describe 'from' do
@@ -9,7 +9,7 @@ describe Picky::Generators::Similarity::Phonetic do
9
9
  it "raises when you don't have the text gem" do
10
10
  instance = Class.new(described_class).allocate
11
11
 
12
- instance.should_receive(:require).any_number_of_times.and_raise LoadError
12
+ instance.should_receive(:require).at_least(1).and_raise LoadError
13
13
 
14
14
  Picky.logger.should_receive(:warn).once.with <<-EXPECTED
15
15
  Warning: text gem missing!
@@ -21,18 +21,18 @@ describe Picky::Index do
21
21
 
22
22
  context "with stubbed categories" do
23
23
  before(:each) do
24
- @categories = stub :categories
24
+ @categories = double :categories
25
25
 
26
26
  @index = described_class.new :some_name
27
27
  @index.category :some_category_name1
28
28
  @index.category :some_category_name2
29
29
 
30
- @index.stub! :categories => @categories
30
+ @index.stub :categories => @categories
31
31
  end
32
32
 
33
33
  describe "load" do
34
34
  it "forwards to each category" do
35
- @categories.should_receive(:load).once.with
35
+ @categories.should_receive(:load).once.with no_args
36
36
 
37
37
  @index.load
38
38
  end
@@ -4,7 +4,7 @@ describe Picky::Index do
4
4
 
5
5
  describe 'tokenizer' do
6
6
  context 'with tokenizer' do
7
- let(:tokenizer) { stub :tokenizer, :tokenize => '' }
7
+ let(:tokenizer) { double :tokenizer, :tokenize => '' }
8
8
  let(:index) do
9
9
  the_tokenizer = tokenizer
10
10
  described_class.new :some_name do
@@ -59,7 +59,7 @@ describe Picky::Index do
59
59
  end
60
60
 
61
61
  it 'does things in order' do
62
- scheduler = stub :scheduler, :fork? => false, :finish => nil
62
+ scheduler = double :scheduler, :fork? => false, :finish => nil
63
63
 
64
64
  index.should_receive(:prepare).once.with(scheduler).ordered
65
65
  index.should_receive(:cache).once.with(scheduler).ordered
@@ -69,7 +69,7 @@ describe Picky::Index do
69
69
  end
70
70
  context 'with non#each source' do
71
71
  it 'raises' do
72
- the_source = stub :source, :harvest => nil
72
+ the_source = double :source, :harvest => nil
73
73
  expect {
74
74
  described_class.new :some_name do
75
75
  source the_source
@@ -94,7 +94,7 @@ ERROR
94
94
  end
95
95
  describe 'source' do
96
96
  it 'can be set with this method' do
97
- source = stub :source, :each => [].each
97
+ source = double :source, :each => [].each
98
98
 
99
99
  @index.source source
100
100
 
@@ -111,7 +111,7 @@ ERROR
111
111
  end
112
112
  context 'with categories' do
113
113
  before(:each) do
114
- @index.category :some_name, :source => stub(:source)
114
+ @index.category :some_name, :source => double(:source)
115
115
  end
116
116
  it 'returns it if found' do
117
117
  @index[:some_name].should_not == nil
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe Picky::Index do
6
6
 
7
- let(:some_source) { stub :source, :each => nil, :inspect => 'some_source' }
7
+ let(:some_source) { double :source, :each => nil, :inspect => 'some_source' }
8
8
 
9
9
  context 'initializer' do
10
10
  it 'works' do
@@ -24,7 +24,7 @@ describe Picky::Index do
24
24
  expect { described_class.new :some_index_name do source { [] } end }.to_not raise_error
25
25
  end
26
26
  it 'evaluates the source every time' do
27
- expector = stub :expector
27
+ expector = double :expector
28
28
 
29
29
  data = described_class.new :some_index_name do
30
30
  source do
@@ -32,7 +32,7 @@ describe Picky::Index do
32
32
  end
33
33
  end
34
34
 
35
- expector.should_receive(:call).twice.with()
35
+ expector.should_receive(:call).twice.with no_args
36
36
 
37
37
  data.prepare
38
38
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Picky::Wrappers::Bundle::Calculation do
4
4
 
5
5
  before(:each) do
6
- @bundle = stub :bundle
6
+ @bundle = double :bundle
7
7
  @calculation = described_class.new @bundle
8
8
  end
9
9
 
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Picky::Wrappers::Bundle::Wrapper do
4
4
 
5
5
  before(:each) do
6
- @bundle = stub :bundle
6
+ @bundle = double :bundle
7
7
 
8
8
  @calculation = described_class.new @bundle
9
9
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Picky::Indexers::Base do
4
4
 
5
- let(:some_index_or_category) { stub :some_index_or_category, :name => 'some_index_or_category' }
5
+ let(:some_index_or_category) { double :some_index_or_category, :name => 'some_index_or_category' }
6
6
  let(:indexer) { described_class.new some_index_or_category }
7
7
 
8
8
  describe 'index_or_category' do
@@ -13,14 +13,14 @@ describe Picky::Indexers::Base do
13
13
 
14
14
  describe 'source' do
15
15
  it 'forwards it to the index or category' do
16
- some_index_or_category.should_receive(:source).once.with
16
+ some_index_or_category.should_receive(:source).once.with no_args
17
17
 
18
18
  indexer.source
19
19
  end
20
20
  it 'raises when none is there' do
21
- some_index_or_category.should_receive(:source).any_number_of_times.and_return nil
21
+ some_index_or_category.should_receive(:source).at_least(1).and_return nil
22
22
 
23
- indexer.stub! :process
23
+ indexer.stub :process
24
24
 
25
25
  expect {
26
26
  indexer.prepare Picky::Categories.new
@@ -30,19 +30,19 @@ describe Picky::Indexers::Base do
30
30
 
31
31
  describe 'prepare' do
32
32
  before(:each) do
33
- some_index_or_category.should_receive(:source).any_number_of_times.and_return :some_source
33
+ some_index_or_category.should_receive(:source).at_least(1).and_return :some_source
34
34
  end
35
35
  it 'processes' do
36
- categories = stub :categories, :empty => nil, :cache => nil
36
+ categories = double :categories, :empty => nil, :cache => nil
37
37
 
38
38
  indexer.should_receive(:process).once.with :some_source, categories, anything
39
39
 
40
40
  indexer.prepare categories
41
41
  end
42
42
  it 'calls the right methods on the categories' do
43
- indexer.stub! :process
43
+ indexer.stub :process
44
44
 
45
- categories = stub :categories
45
+ categories = double :categories
46
46
 
47
47
  categories.should_receive(:empty).once.ordered
48
48
 
@@ -5,9 +5,9 @@ describe Picky::Indexers::Parallel do
5
5
  thing = Struct.new :id, :text
6
6
 
7
7
  before(:each) do
8
- @index = Picky::Index.new(:test) # stub :index, :name => :some_index, :source => @source, :backend => stub(:backend)
8
+ @index = Picky::Index.new(:test) # double :index, :name => :some_index, :source => @source, :backend => double(:backend)
9
9
  @indexer = described_class.new @index
10
- @indexer.stub! :timed_exclaim
10
+ @indexer.stub :timed_exclaim
11
11
  end
12
12
 
13
13
  context 'with untokenized category' do
@@ -24,8 +24,8 @@ describe Picky::Indexers::Parallel do
24
24
 
25
25
  describe 'flush' do
26
26
  it 'flushes to joined cache to the file and clears it' do
27
- cache = stub :cache
28
- file = stub :file
27
+ cache = double :cache
28
+ file = double :file
29
29
 
30
30
  cache.should_receive(:join).once.and_return :joined
31
31
  file.should_receive(:write).once.with(:joined).and_return :joined
@@ -59,8 +59,8 @@ describe Picky::Indexers::Parallel do
59
59
 
60
60
  describe 'flush' do
61
61
  it 'flushes to joined cache to the file and clears it' do
62
- cache = stub :cache
63
- file = stub :file
62
+ cache = double :cache
63
+ file = double :file
64
64
 
65
65
  cache.should_receive(:join).once.and_return :joined
66
66
  file.should_receive(:write).once.with(:joined).and_return :joined
@@ -3,15 +3,15 @@ require 'spec_helper'
3
3
  describe Picky::Indexers::Serial do
4
4
 
5
5
  before(:each) do
6
- @tokenizer = stub :tokenizer
7
- @source = stub :source
8
- @category = stub :category,
6
+ @tokenizer = double :tokenizer
7
+ @source = double :source
8
+ @category = double :category,
9
9
  :identifier => :some_identifier,
10
10
  :tokenizer => @tokenizer,
11
11
  :source => @source
12
12
 
13
13
  @indexer = described_class.new @category
14
- @indexer.stub! :timed_exclaim
14
+ @indexer.stub :timed_exclaim
15
15
  end
16
16
 
17
17
  describe "source" do
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Picky::Indexes do
4
4
 
5
5
  before(:each) do
6
- @index = stub :some_index, :name => :some_index
6
+ @index = double :some_index, :name => :some_index
7
7
  @indexes = described_class.instance
8
8
  end
9
9
 
@@ -15,8 +15,8 @@ describe Picky::Indexes do
15
15
  describe 'methods' do
16
16
  let(:indexes) { described_class.new }
17
17
  before(:each) do
18
- @index1 = stub :index1, :name => :index1
19
- @index2 = stub :index2, :name => :index2
18
+ @index1 = double :index1, :name => :index1
19
+ @index2 = double :index2, :name => :index2
20
20
  indexes.register @index1
21
21
  indexes.register @index2
22
22
  end
@@ -50,8 +50,8 @@ describe Picky::Indexes do
50
50
  end
51
51
  describe 'load' do
52
52
  it 'calls load on each in order' do
53
- @index1.should_receive(:load).once.with.ordered
54
- @index2.should_receive(:load).once.with.ordered
53
+ @index1.should_receive(:load).once.with(no_args).ordered
54
+ @index2.should_receive(:load).once.with(no_args).ordered
55
55
 
56
56
  indexes.load
57
57
  end
@@ -14,14 +14,14 @@ describe Picky::Indexes do
14
14
  describe 'methods' do
15
15
  let(:indexes) { described_class.new }
16
16
  before(:each) do
17
- @index1 = stub :index1, :name => :index1
18
- @index2 = stub :index2, :name => :index2
17
+ @index1 = double :index1, :name => :index1
18
+ @index2 = double :index2, :name => :index2
19
19
  indexes.register @index1
20
20
  indexes.register @index2
21
21
  end
22
22
  describe 'index' do
23
23
  it 'prepares and caches each' do
24
- scheduler = stub :scheduler, :fork? => false, :finish => nil
24
+ scheduler = double :scheduler, :fork? => false, :finish => nil
25
25
 
26
26
  @index1.should_receive(:prepare).once.with(scheduler).ordered
27
27
  @index2.should_receive(:prepare).once.with(scheduler).ordered
@@ -47,8 +47,8 @@ describe Picky::Indexes do
47
47
  def self.it_forwards_each name
48
48
  describe name do
49
49
  it "calls #{name} on each in order" do
50
- @index1.should_receive(name).once.with.ordered
51
- @index2.should_receive(name).once.with.ordered
50
+ @index1.should_receive(name).once.with(no_args).ordered
51
+ @index2.should_receive(name).once.with(no_args).ordered
52
52
 
53
53
  indexes.send name
54
54
  end
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Picky::Indexes do
4
4
 
5
- let(:index) { stub :some_index, :name => :some_index }
6
- let(:index2) { stub :some_index2, :name => :some_index }
5
+ let(:index) { double :some_index, :name => :some_index }
6
+ let(:index2) { double :some_index2, :name => :some_index }
7
7
 
8
8
  context 'with instance' do
9
9
  let(:indexes) { Picky::Indexes.new }