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
@@ -5,11 +5,11 @@ require 'spec_helper'
5
5
  describe Picky::Interfaces::LiveParameters::MasterChild do
6
6
 
7
7
  before(:each) do
8
- @parent = stub :parent
9
- @child = stub :child
10
- IO.stub! :pipe => [@child, @parent]
8
+ @parent = double :parent
9
+ @child = double :child
10
+ IO.stub :pipe => [@child, @parent]
11
11
  @parameters = described_class.new
12
- @parameters.stub! :exclaim
12
+ @parameters.stub :exclaim
13
13
  end
14
14
 
15
15
  describe Picky::Interfaces::LiveParameters::MasterChild::CouldNotUpdateConfigurationError do
@@ -43,10 +43,10 @@ describe Picky::Interfaces::LiveParameters::MasterChild do
43
43
  describe 'parameters' do
44
44
  context 'all goes well' do
45
45
  it 'does a few things in order' do
46
- @parameters.should_receive(:close_child).once.with().ordered
46
+ @parameters.should_receive(:close_child).once.with(no_args).ordered
47
47
  @parameters.should_receive(:try_updating_configuration_with).once.with(:a => :b).ordered
48
48
  @parameters.should_receive(:write_parent).once.with(:a => :b).ordered
49
- @parameters.should_receive(:extract_configuration).once.with().ordered
49
+ @parameters.should_receive(:extract_configuration).once.with(no_args).ordered
50
50
 
51
51
  @parameters.parameters :a => :b
52
52
  end
@@ -66,7 +66,7 @@ describe Picky::Interfaces::LiveParameters::MasterChild do
66
66
 
67
67
  describe 'harakiri' do
68
68
  before(:each) do
69
- Process.stub! :pid => :some_pid
69
+ Process.stub :pid => :some_pid
70
70
  end
71
71
  it 'kills itself' do
72
72
  Process.should_receive(:kill).once.with :QUIT, :some_pid
@@ -77,7 +77,7 @@ describe Picky::Interfaces::LiveParameters::MasterChild do
77
77
 
78
78
  describe 'write_parent' do
79
79
  before(:each) do
80
- Process.stub! :pid => :some_pid
80
+ Process.stub :pid => :some_pid
81
81
  end
82
82
  it 'calls the parent' do
83
83
  @parent.should_receive(:write).once.with "[:some_pid, {:a=>:b}];;;"
@@ -89,7 +89,7 @@ describe Picky::Interfaces::LiveParameters::MasterChild do
89
89
  describe 'close_child' do
90
90
  context 'child is closed' do
91
91
  before(:each) do
92
- @child.stub! :closed? => true
92
+ @child.stub :closed? => true
93
93
  end
94
94
  it 'does not receive close' do
95
95
  @child.should_receive(:close).never
@@ -99,10 +99,10 @@ describe Picky::Interfaces::LiveParameters::MasterChild do
99
99
  end
100
100
  context 'child not yet closed' do
101
101
  before(:each) do
102
- @child.stub! :closed? => false
102
+ @child.stub :closed? => false
103
103
  end
104
104
  it 'does receives close' do
105
- @child.should_receive(:close).once.with()
105
+ @child.should_receive(:close).once.with no_args
106
106
 
107
107
  @parameters.close_child
108
108
  end
@@ -131,7 +131,7 @@ describe Picky::Interfaces::LiveParameters::MasterChild do
131
131
  describe 'kill_each_worker_except' do
132
132
  context 'worker pid in the worker pids' do
133
133
  before(:each) do
134
- @parameters.stub! :worker_pids => [1,2,3,4]
134
+ @parameters.stub :worker_pids => [1,2,3,4]
135
135
  end
136
136
  it 'kills each except the one' do
137
137
  @parameters.should_receive(:kill_worker).once.with(:KILL, 1)
@@ -144,7 +144,7 @@ describe Picky::Interfaces::LiveParameters::MasterChild do
144
144
  end
145
145
  context 'worker pid not in the worker pids (unrealistic, but...)' do
146
146
  before(:each) do
147
- @parameters.stub! :worker_pids => [1,2,3,4]
147
+ @parameters.stub :worker_pids => [1,2,3,4]
148
148
  end
149
149
  it 'kills each except the one' do
150
150
  @parameters.should_receive(:kill_worker).once.with(:KILL, 1)
@@ -5,11 +5,11 @@ require 'spec_helper'
5
5
  describe Picky::Interfaces::LiveParameters::Unicorn do
6
6
 
7
7
  before(:each) do
8
- @parent = stub :parent
9
- @child = stub :child
10
- IO.stub! :pipe => [@child, @parent]
8
+ @parent = double :parent
9
+ @child = double :child
10
+ IO.stub :pipe => [@child, @parent]
11
11
  @parameters = described_class.new
12
- @parameters.stub! :exclaim
12
+ @parameters.stub :exclaim
13
13
  end
14
14
 
15
15
  describe Picky::Interfaces::LiveParameters::Unicorn::CouldNotUpdateConfigurationError do
@@ -43,10 +43,10 @@ describe Picky::Interfaces::LiveParameters::Unicorn do
43
43
  describe 'parameters' do
44
44
  context 'all goes well' do
45
45
  it 'does a few things in order' do
46
- @parameters.should_receive(:close_child).once.with().ordered
46
+ @parameters.should_receive(:close_child).once.with(no_args).ordered
47
47
  @parameters.should_receive(:try_updating_configuration_with).once.with(:a => :b).ordered
48
48
  @parameters.should_receive(:write_parent).once.with(:a => :b).ordered
49
- @parameters.should_receive(:extract_configuration).once.with().ordered
49
+ @parameters.should_receive(:extract_configuration).once.with(no_args).ordered
50
50
 
51
51
  @parameters.parameters :a => :b
52
52
  end
@@ -66,7 +66,7 @@ describe Picky::Interfaces::LiveParameters::Unicorn do
66
66
 
67
67
  describe 'harakiri' do
68
68
  before(:each) do
69
- Process.stub! :pid => :some_pid
69
+ Process.stub :pid => :some_pid
70
70
  end
71
71
  it 'kills itself' do
72
72
  Process.should_receive(:kill).once.with :QUIT, :some_pid
@@ -77,7 +77,7 @@ describe Picky::Interfaces::LiveParameters::Unicorn do
77
77
 
78
78
  describe 'write_parent' do
79
79
  before(:each) do
80
- Process.stub! :pid => :some_pid
80
+ Process.stub :pid => :some_pid
81
81
  end
82
82
  it 'calls the parent' do
83
83
  @parent.should_receive(:write).once.with "[:some_pid, {:a=>:b}];;;"
@@ -89,7 +89,7 @@ describe Picky::Interfaces::LiveParameters::Unicorn do
89
89
  describe 'close_child' do
90
90
  context 'child is closed' do
91
91
  before(:each) do
92
- @child.stub! :closed? => true
92
+ @child.stub :closed? => true
93
93
  end
94
94
  it 'does not receive close' do
95
95
  @child.should_receive(:close).never
@@ -99,10 +99,10 @@ describe Picky::Interfaces::LiveParameters::Unicorn do
99
99
  end
100
100
  context 'child not yet closed' do
101
101
  before(:each) do
102
- @child.stub! :closed? => false
102
+ @child.stub :closed? => false
103
103
  end
104
104
  it 'does receives close' do
105
- @child.should_receive(:close).once.with()
105
+ @child.should_receive(:close).once.with no_args
106
106
 
107
107
  @parameters.close_child
108
108
  end
@@ -131,7 +131,7 @@ describe Picky::Interfaces::LiveParameters::Unicorn do
131
131
  describe 'kill_each_worker_except' do
132
132
  context 'worker pid in the worker pids' do
133
133
  before(:each) do
134
- @parameters.stub! :worker_pids => [1,2,3,4]
134
+ @parameters.stub :worker_pids => [1,2,3,4]
135
135
  end
136
136
  it 'kills each except the one' do
137
137
  @parameters.should_receive(:kill_worker).once.with(:KILL, 1)
@@ -144,7 +144,7 @@ describe Picky::Interfaces::LiveParameters::Unicorn do
144
144
  end
145
145
  context 'worker pid not in the worker pids (unrealistic, but...)' do
146
146
  before(:each) do
147
- @parameters.stub! :worker_pids => [1,2,3,4]
147
+ @parameters.stub :worker_pids => [1,2,3,4]
148
148
  end
149
149
  it 'kills each except the one' do
150
150
  @parameters.should_receive(:kill_worker).once.with(:KILL, 1)
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Picky::Loader do
4
4
 
5
5
  before(:each) do
6
- described_class.stub! :exclaim
6
+ described_class.stub :exclaim
7
7
  @loader_path = File.absolute_path("#{File.dirname(__FILE__)}/../../lib/picky/loader.rb")
8
8
  end
9
9
 
@@ -36,7 +36,7 @@ describe Picky::Loader do
36
36
 
37
37
  describe 'load_framework' do
38
38
  before(:each) do
39
- described_class.stub! :load_relative
39
+ described_class.stub :load_relative
40
40
  end
41
41
  it 'does ok' do
42
42
  lambda { described_class.load_framework }.should_not raise_error
@@ -45,7 +45,7 @@ describe Picky::Loader do
45
45
 
46
46
  describe 'load_self' do
47
47
  before(:each) do
48
- described_class.stub! :load
48
+ described_class.stub :load
49
49
  end
50
50
  after(:each) do
51
51
  described_class.load_self
@@ -58,9 +58,9 @@ describe Picky::Loader do
58
58
  describe 'reload' do
59
59
  before(:each) do
60
60
  load @loader_path
61
- described_class.stub! :load_framework
62
- described_class.stub! :load_application
63
- Dir.stub! :chdir
61
+ described_class.stub :load_framework
62
+ described_class.stub :load_application
63
+ Dir.stub :chdir
64
64
  end
65
65
  it 'should call the right methods in order' do
66
66
  described_class.should_receive(:load_self).ordered
@@ -84,9 +84,9 @@ describe Picky::Loader do
84
84
  describe 'load' do
85
85
  before(:each) do
86
86
  load @loader_path
87
- described_class.stub! :load_framework
88
- described_class.stub! :load_application
89
- Dir.stub! :chdir
87
+ described_class.stub :load_framework
88
+ described_class.stub :load_application
89
+ Dir.stub :chdir
90
90
  end
91
91
  after(:each) do
92
92
  described_class.load
@@ -4,14 +4,21 @@ describe Picky::Loggers::Verbose do
4
4
 
5
5
  let(:index) { Picky::Index.new :some_index }
6
6
  let(:category) { Picky::Category.new :some_category, index }
7
- let(:file) { stub :file, :path => 'some/path' }
7
+ let(:file) { double :file, :path => 'some/path' }
8
8
  let(:io) { StringIO.new }
9
9
  let(:logger) { described_class.new thing }
10
10
  context 'with Logger' do
11
11
  let(:thing) { Logger.new io }
12
+ before :each do
13
+ # Explicitly define formatting for these specs.
14
+ #
15
+ thing.formatter = proc do |severity, datetime, progname, msg|
16
+ "#{msg}\n"
17
+ end
18
+ end
12
19
  describe 'more complicated test case' do
13
20
  it 'is correct' do
14
- Time.stub! :now => Time.new('zeros')
21
+ Time.stub :now => Time.new('zeros')
15
22
 
16
23
  logger.info 'Tokenizing '
17
24
  logger.tokenize category, file
@@ -34,7 +41,7 @@ describe Picky::Loggers::Verbose do
34
41
  let(:thing) { io }
35
42
  describe 'more complicated test case' do
36
43
  it 'is correct' do
37
- Time.stub! :now => Time.new('zeros')
44
+ Time.stub :now => Time.new('zeros')
38
45
 
39
46
  logger.info 'Tokenizing '
40
47
  logger.tokenize category, file
@@ -3,21 +3,21 @@ require 'spec_helper'
3
3
  describe Picky::Query::Allocation do
4
4
 
5
5
  before(:each) do
6
- @backend = stub :backend
7
- @index = stub :index, :result_identifier => :some_result_identifier, :backend => @backend
8
- @combinations = stub :combinations, :empty? => false
6
+ @backend = double :backend
7
+ @index = double :index, :result_identifier => :some_result_identifier, :backend => @backend
8
+ @combinations = double :combinations, :empty? => false
9
9
  @allocation = described_class.new @index, @combinations
10
10
  end
11
11
 
12
12
  describe "to_s" do
13
13
  before(:each) do
14
- @combinations.stub! :to_result => 'combinations_result'
14
+ @combinations.stub :to_result => 'combinations_result'
15
15
  end
16
16
  context "allocation.count > 0" do
17
17
  before(:each) do
18
- @allocation.stub! :count => 10
19
- @allocation.stub! :score => :score
20
- @allocation.stub! :ids => :ids
18
+ @allocation.stub :count => 10
19
+ @allocation.stub :score => :score
20
+ @allocation.stub :ids => :ids
21
21
  end
22
22
  it "represents correctly" do
23
23
  @allocation.to_s.should == "Allocation([:some_result_identifier, :score, 10, \"combinations_result\", :ids])"
@@ -36,7 +36,7 @@ describe Picky::Query::Allocation do
36
36
  describe 'process!' do
37
37
  context 'no ids' do
38
38
  before(:each) do
39
- @allocation.stub! :calculate_ids => []
39
+ @allocation.stub :calculate_ids => []
40
40
  end
41
41
  it 'should process right' do
42
42
  @allocation.process!(0, 0).should == []
@@ -53,7 +53,7 @@ describe Picky::Query::Allocation do
53
53
  end
54
54
  context 'with ids' do
55
55
  before(:each) do
56
- @allocation.stub! :calculate_ids => [1,2,3,4,5,6,7,8,9,10]
56
+ @allocation.stub :calculate_ids => [1,2,3,4,5,6,7,8,9,10]
57
57
  end
58
58
  it 'should process right' do
59
59
  @allocation.process!(0, 0).should == []
@@ -79,7 +79,7 @@ describe Picky::Query::Allocation do
79
79
  end
80
80
  context 'with symbol ids' do
81
81
  before(:each) do
82
- @allocation.stub! :calculate_ids => [:a,:b,:c,:d,:e,:f,:g,:h,:i,:j]
82
+ @allocation.stub :calculate_ids => [:a,:b,:c,:d,:e,:f,:g,:h,:i,:j]
83
83
  end
84
84
  it 'should process right' do
85
85
  @allocation.process!(0, 0).should == []
@@ -107,7 +107,7 @@ describe Picky::Query::Allocation do
107
107
 
108
108
  describe "subject" do
109
109
  before(:each) do
110
- @allocation.stub! :calculate_ids => [1,2,3,4,5,6,7,8,9,10]
110
+ @allocation.stub :calculate_ids => [1,2,3,4,5,6,7,8,9,10]
111
111
  end
112
112
  it 'should process right' do
113
113
  @allocation.process_with_illegals!(0, 0, [1,3,7]).should == []
@@ -135,12 +135,12 @@ describe Picky::Query::Allocation do
135
135
  describe 'to_result' do
136
136
  context 'with few combinations' do
137
137
  before(:each) do
138
- @allocation = described_class.new @index, stub(:combinations, :empty? => false, :to_result => [:some_result])
138
+ @allocation = described_class.new @index, double(:combinations, :empty? => false, :to_result => [:some_result])
139
139
  @allocation.instance_variable_set :@score, :some_score
140
140
  end
141
141
  context 'with ids' do
142
142
  it 'should output an array of information' do
143
- @backend.stub! :ids => [1,2,3]
143
+ @backend.stub :ids => [1,2,3]
144
144
 
145
145
  @allocation.process! 20, 0
146
146
 
@@ -150,7 +150,7 @@ describe Picky::Query::Allocation do
150
150
  end
151
151
  context 'with results' do
152
152
  before(:each) do
153
- combinations = stub :combinations,
153
+ combinations = double :combinations,
154
154
  :empty? => false,
155
155
  :to_result => [:some_result1, :some_result2]
156
156
  @allocation = described_class.new @index, combinations
@@ -158,7 +158,7 @@ describe Picky::Query::Allocation do
158
158
  end
159
159
  context 'with ids' do
160
160
  it 'should output an array of information' do
161
- @backend.stub! :ids => [1,2,3]
161
+ @backend.stub :ids => [1,2,3]
162
162
 
163
163
  @allocation.process! 20, 0
164
164
 
@@ -168,11 +168,11 @@ describe Picky::Query::Allocation do
168
168
  end
169
169
  context 'without results' do
170
170
  before(:each) do
171
- @allocation = described_class.new @index, stub(:combinations, :empty? => true)
171
+ @allocation = described_class.new @index, double(:combinations, :empty? => true)
172
172
  @allocation.instance_variable_set :@score, :some_score
173
173
  end
174
174
  it 'should return nil' do
175
- @backend.stub! :ids => []
175
+ @backend.stub :ids => []
176
176
 
177
177
  @allocation.process! 20, 0
178
178
 
@@ -185,7 +185,7 @@ describe Picky::Query::Allocation do
185
185
  context 'non-empty combinations' do
186
186
  it 'should forward to backend and combinations' do
187
187
  @combinations.should_receive(:score).once.and_return 1
188
- boosts = stub :weights, :boost_for => 2
188
+ boosts = double :weights, :boost_for => 2
189
189
 
190
190
  @allocation.calculate_score(boosts).should == 3
191
191
  end
@@ -220,10 +220,10 @@ describe Picky::Query::Allocation do
220
220
 
221
221
  describe "process!" do
222
222
  before(:each) do
223
- @amount = stub :amount
224
- @offset = stub :offset
225
- @ids = stub :ids, :size => :some_original_size, :slice! => :some_sliced_ids
226
- @allocation.stub! :calculate_ids => @ids
223
+ @amount = double :amount
224
+ @offset = double :offset
225
+ @ids = double :ids, :size => :some_original_size, :slice! => :some_sliced_ids
226
+ @allocation.stub :calculate_ids => @ids
227
227
  end
228
228
  it 'should calculate_ids' do
229
229
  @allocation.should_receive(:calculate_ids).once.with(@amount, @offset).and_return @ids
@@ -4,9 +4,9 @@ describe Picky::Query::Allocations do
4
4
 
5
5
  describe 'reduce_to' do
6
6
  before(:each) do
7
- @allocation1 = stub :allocation1
8
- @allocation2 = stub :allocation2
9
- @allocation3 = stub :allocation3
7
+ @allocation1 = double :allocation1
8
+ @allocation2 = double :allocation2
9
+ @allocation3 = double :allocation3
10
10
  @allocations = described_class.new [@allocation1, @allocation2, @allocation3]
11
11
  end
12
12
  it 'should do nothing' do
@@ -18,9 +18,9 @@ describe Picky::Query::Allocations do
18
18
 
19
19
  describe 'remove' do
20
20
  before(:each) do
21
- @allocation1 = stub :allocation1
22
- @allocation2 = stub :allocation2
23
- @allocation3 = stub :allocation3
21
+ @allocation1 = double :allocation1
22
+ @allocation2 = double :allocation2
23
+ @allocation3 = double :allocation3
24
24
  @allocations = described_class.new [@allocation1, @allocation2, @allocation3]
25
25
  end
26
26
  context 'identifiers empty' do
@@ -45,9 +45,9 @@ describe Picky::Query::Allocations do
45
45
  describe 'ids' do
46
46
  context 'integers' do
47
47
  before(:each) do
48
- @allocation1 = stub :allocation1, :ids => [1, 2, 3, 4]
49
- @allocation2 = stub :allocation2, :ids => [5, 6, 7]
50
- @allocation3 = stub :allocation3, :ids => [8, 9]
48
+ @allocation1 = double :allocation1, :ids => [1, 2, 3, 4]
49
+ @allocation2 = double :allocation2, :ids => [5, 6, 7]
50
+ @allocation3 = double :allocation3, :ids => [8, 9]
51
51
  @allocations = described_class.new [@allocation1, @allocation2, @allocation3]
52
52
  end
53
53
  it 'should return the right amount of ids' do
@@ -62,9 +62,9 @@ describe Picky::Query::Allocations do
62
62
  end
63
63
  context 'symbols' do
64
64
  before(:each) do
65
- @allocation1 = stub :allocation1, :ids => [:a, :b, :c, :d]
66
- @allocation2 = stub :allocation2, :ids => [:e, :f, :g]
67
- @allocation3 = stub :allocation3, :ids => [:h, :i]
65
+ @allocation1 = double :allocation1, :ids => [:a, :b, :c, :d]
66
+ @allocation2 = double :allocation2, :ids => [:e, :f, :g]
67
+ @allocation3 = double :allocation3, :ids => [:h, :i]
68
68
  @allocations = described_class.new [@allocation1, @allocation2, @allocation3]
69
69
  end
70
70
  it 'should return the right amount of ids' do
@@ -81,9 +81,9 @@ describe Picky::Query::Allocations do
81
81
 
82
82
  describe 'process!' do
83
83
  before(:each) do
84
- @allocation1 = stub :allocation1, :count => 4, ids: [1, 2, 3, 4]
85
- @allocation2 = stub :allocation2, :count => 3, ids: [5, 6, 7]
86
- @allocation3 = stub :allocation3, :count => 2, ids: [8, 9]
84
+ @allocation1 = double :allocation1, :count => 4, ids: [1, 2, 3, 4]
85
+ @allocation2 = double :allocation2, :count => 3, ids: [5, 6, 7]
86
+ @allocation3 = double :allocation3, :count => 2, ids: [8, 9]
87
87
  @allocations = described_class.new [@allocation1, @allocation2, @allocation3]
88
88
  end
89
89
  describe 'lazy evaluation' do
@@ -284,19 +284,19 @@ describe Picky::Query::Allocations do
284
284
  describe 'to_result' do
285
285
  context 'all allocations have results' do
286
286
  before(:each) do
287
- @allocation = stub :allocation
287
+ @allocation = double :allocation
288
288
  @allocations = described_class.new [@allocation, @allocation, @allocation]
289
289
  end
290
290
  it 'should forward to each allocation with no params' do
291
- @allocation.should_receive(:to_result).exactly(3).times.with
291
+ @allocation.should_receive(:to_result).exactly(3).times.with no_args
292
292
 
293
293
  @allocations.to_result
294
294
  end
295
295
  end
296
296
  context 'one allocation has no results' do
297
297
  before(:each) do
298
- @allocation = stub :allocation, :to_result => :some_result
299
- @no_result_allocation = stub :no_results, :to_result => nil
298
+ @allocation = double :allocation, :to_result => :some_result
299
+ @no_result_allocation = double :no_results, :to_result => nil
300
300
  @allocations = described_class.new [@allocation, @no_result_allocation, @allocation]
301
301
  end
302
302
  it 'should forward to each allocation with the same params' do
@@ -309,9 +309,9 @@ describe Picky::Query::Allocations do
309
309
  context 'with allocations' do
310
310
  before(:each) do
311
311
  @allocations = described_class.new [
312
- stub(:allocation, :process! => (1..10).to_a, :count => 10),
313
- stub(:allocation, :process! => (1..80).to_a, :count => 80),
314
- stub(:allocation, :process! => (1..20).to_a, :count => 20)
312
+ double(:allocation, :process! => (1..10).to_a, :count => 10),
313
+ double(:allocation, :process! => (1..80).to_a, :count => 80),
314
+ double(:allocation, :process! => (1..20).to_a, :count => 20)
315
315
  ]
316
316
  end
317
317
  it 'should traverse the allocations and sum the counts' do
@@ -334,31 +334,31 @@ describe Picky::Query::Allocations do
334
334
 
335
335
  describe "each" do
336
336
  before(:each) do
337
- @internal_allocations = mock :internal_allocations
337
+ @internal_allocations = double :internal_allocations
338
338
  @allocations = described_class.new @internal_allocations
339
339
  end
340
340
  it "should forward to the internal allocations" do
341
341
  stub_proc = lambda {}
342
- @internal_allocations.should_receive(:each).once.with &stub_proc
342
+ @internal_allocations.should_receive(:each).once.with no_args, &stub_proc
343
343
 
344
344
  @allocations.each &stub_proc
345
345
  end
346
346
  end
347
347
  describe "inject" do
348
348
  before(:each) do
349
- @internal_allocations = mock :internal_allocations
349
+ @internal_allocations = double :internal_allocations
350
350
  @allocations = described_class.new @internal_allocations
351
351
  end
352
352
  it "should forward to the internal allocations" do
353
353
  stub_proc = lambda {}
354
- @internal_allocations.should_receive(:inject).once.with &stub_proc
354
+ @internal_allocations.should_receive(:inject).once.with no_args, &stub_proc
355
355
 
356
356
  @allocations.inject &stub_proc
357
357
  end
358
358
  end
359
359
  describe "empty?" do
360
360
  before(:each) do
361
- @internal_allocations = mock :internal_allocations
361
+ @internal_allocations = double :internal_allocations
362
362
  @allocations = described_class.new @internal_allocations
363
363
  end
364
364
  it "should forward to the internal allocations array" do
@@ -369,8 +369,8 @@ describe Picky::Query::Allocations do
369
369
 
370
370
  describe "to_s" do
371
371
  before(:each) do
372
- @allocation = stub :allocation, :to_result => :some_result
373
- @no_result_allocation = stub :no_results, :to_result => nil
372
+ @allocation = double :allocation, :to_result => :some_result
373
+ @no_result_allocation = double :no_results, :to_result => nil
374
374
  @allocations = described_class.new [@allocation, @no_result_allocation, @allocation]
375
375
  end
376
376
  it "should forward to the internal allocations array" do
@@ -382,9 +382,9 @@ describe Picky::Query::Allocations do
382
382
  context 'some allocations' do
383
383
  before(:each) do
384
384
  @allocations = described_class.new [
385
- stub(:allocation, :process! => (1..10).to_a, :count => 10),
386
- stub(:allocation, :process! => (1..80).to_a, :count => 80),
387
- stub(:allocation, :process! => (1..20).to_a, :count => 20)
385
+ double(:allocation, :process! => (1..10).to_a, :count => 10),
386
+ double(:allocation, :process! => (1..80).to_a, :count => 80),
387
+ double(:allocation, :process! => (1..20).to_a, :count => 20)
388
388
  ]
389
389
  end
390
390
  it 'should calculate the right total' do
@@ -22,8 +22,8 @@ describe Picky::Query::Boosts do
22
22
  describe 'boost_for' do
23
23
  it 'gets the category names from the combinations' do
24
24
  combinations = [
25
- stub(:combination1, :category_name => :test1),
26
- stub(:combination1, :category_name => :test2)
25
+ double(:combination1, :category_name => :test1),
26
+ double(:combination1, :category_name => :test2)
27
27
  ]
28
28
 
29
29
  boosts.boost_for(combinations).should == +6
@@ -5,9 +5,9 @@ require 'spec_helper'
5
5
  describe Picky::Query::Combination do
6
6
 
7
7
  before(:each) do
8
- @bundle = stub :bundle, :identifier => :bundle_name
8
+ @bundle = double :bundle, :identifier => :bundle_name
9
9
  @token = Picky::Query::Token.processed('some_text~', 'Some Original~')
10
- @category = stub :category,
10
+ @category = double :category,
11
11
  :bundle_for => @bundle,
12
12
  :name => :some_category_name,
13
13
  :identifier => 'some_category_identifier'
@@ -17,7 +17,7 @@ describe Picky::Query::Combination do
17
17
 
18
18
  describe "to_s" do
19
19
  it "shows the combination's info" do
20
- @token.stub! :to_result => :token_result
20
+ @token.stub :to_result => :token_result
21
21
 
22
22
  @combination.to_s.should == '(bundle_name,some_category_name:token_result)'
23
23
  end
@@ -35,7 +35,7 @@ describe Picky::Query::Combination do
35
35
  end
36
36
  end
37
37
  it 'should return a correct result' do
38
- @token.stub! :to_result => [:some_original_text, :some_text]
38
+ @token.stub :to_result => [:some_original_text, :some_text]
39
39
 
40
40
  @combination.to_result.should == [:some_category_name, :some_original_text, :some_text]
41
41
  end
@@ -54,7 +54,7 @@ describe Picky::Query::Combination do
54
54
  @combination.ids
55
55
  end
56
56
  it 'should not call it twice, but cache' do
57
- @category.stub! :ids => :some_ids
57
+ @category.stub :ids => :some_ids
58
58
  @combination.ids
59
59
 
60
60
  @category.should_receive(:ids).never
@@ -5,15 +5,15 @@ require 'spec_helper'
5
5
  describe Picky::Query::Combinations do
6
6
 
7
7
  before(:each) do
8
- @combinations_ary = stub :combinations_ary
8
+ @combinations_ary = double :combinations_ary
9
9
 
10
10
  @combinations = described_class.new @combinations_ary
11
11
  end
12
12
 
13
13
  describe "to_result" do
14
14
  before(:each) do
15
- @combination1 = stub :combination1, :to_result => :result1
16
- @combination2 = stub :combination2, :to_result => :result2
15
+ @combination1 = double :combination1, :to_result => :result1
16
+ @combination2 = double :combination2, :to_result => :result2
17
17
 
18
18
  @combinations_ary = [@combination1, @combination2]
19
19
 
@@ -26,8 +26,8 @@ describe Picky::Query::Combinations do
26
26
 
27
27
  describe "total_score" do
28
28
  before(:each) do
29
- @combination1 = stub :combination1, :weight => 3.14
30
- @combination2 = stub :combination2, :weight => 2.76
29
+ @combination1 = double :combination1, :weight => 3.14
30
+ @combination2 = double :combination2, :weight => 2.76
31
31
 
32
32
  @combinations_ary = [@combination1, @combination2]
33
33
 
@@ -40,9 +40,9 @@ describe Picky::Query::Combinations do
40
40
 
41
41
  describe 'remove' do
42
42
  before(:each) do
43
- @combination1 = stub :combination1, :category => stub(:other, :name => :other)
44
- @combination2 = stub :combination2, :category => stub(:to_remove, :name => :to_remove)
45
- @combination3 = stub :combination3, :category => stub(:to_remove, :name => :to_remove)
43
+ @combination1 = double :combination1, :category => double(:other, :name => :other)
44
+ @combination2 = double :combination2, :category => double(:to_remove, :name => :to_remove)
45
+ @combination3 = double :combination3, :category => double(:to_remove, :name => :to_remove)
46
46
 
47
47
  @combinations = described_class.new [@combination1, @combination2, @combination3]
48
48
  end