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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0c337f4cbc3ca20bb599c78b9238f4b1bfe5893d
4
+ data.tar.gz: c81c408fd0f601cf23803d4381bdada9b69adec6
5
+ SHA512:
6
+ metadata.gz: f68b91b51dc9fe43467acd3363c13af4282437c247a7c7c07a3284227658217e9aece50a473639e6b3cdaf33174f58c25c12b61466302faeb1ef2754b62e00d5
7
+ data.tar.gz: d25949f5f192dd6177f5d2aa6d770aee90311dd2b0d0d83a7cc31c6b4979d4926b8bf1306108fe258306ca406137c4a400811c9fff599567740316e178f0d4e1
@@ -9,6 +9,7 @@ module Picky
9
9
  :map,
10
10
  :map!,
11
11
  :include?,
12
+ :empty?,
12
13
  :to => :categories
13
14
 
14
15
  each_forward :cache,
@@ -72,7 +72,7 @@ module Picky
72
72
  tokens = text_or_tokens
73
73
  end
74
74
 
75
- format = self.key_format?
75
+ format = key_format?
76
76
  tokens.each { |text| add_tokenized_token id, text, where, format }
77
77
  rescue NoMethodError => e
78
78
  show_informative_add_text_error_message_for e
data/lib/picky/index.rb CHANGED
@@ -376,7 +376,13 @@ INDEX
376
376
  #
377
377
  #
378
378
  def to_s
379
- "#{self.class}(#{name}, result_id: #{result_identifier}, source: #@source, categories: #{categories})"
379
+ s = [
380
+ name,
381
+ "result_id: #{result_identifier}",
382
+ ("source: #{source}" if @source),
383
+ ("categories: #{categories}" unless categories.empty?)
384
+ ].compact
385
+ "#{self.class}(#{s.join(', ')})"
380
386
  end
381
387
 
382
388
  end
@@ -4,7 +4,9 @@ module Picky
4
4
 
5
5
  class Indexes
6
6
 
7
+ # Checks if multiple backends are used in the same search instance.
7
8
  #
9
+ # Using multiple backends for the same search are not yet possible.
8
10
  #
9
11
  class Check
10
12
 
@@ -24,19 +24,6 @@ module Picky
24
24
  end
25
25
  combinations.empty? && combinations || [Query::Combination::Or.new(combinations)]
26
26
  end
27
-
28
- # # Returns the token in the form
29
- # # ['original:Text', 'processedtext']
30
- # #
31
- # def to_result
32
- # [originals.join('|'), texts.join('|')]
33
- # end
34
-
35
- # # Just join the token original texts.
36
- # #
37
- # def to_s
38
- # "#{self.class}(#{originals.join '|'})"
39
- # end
40
27
 
41
28
  end
42
29
 
data/lib/picky/results.rb CHANGED
@@ -66,10 +66,12 @@ module Picky
66
66
  # Returns a hash with the allocations, offset, duration and total.
67
67
  #
68
68
  def to_hash
69
- { allocations: allocations.to_result,
69
+ {
70
+ allocations: allocations.to_result,
70
71
  offset: offset,
71
72
  duration: duration,
72
- total: total }
73
+ total: total
74
+ }
73
75
  end
74
76
 
75
77
  # Convert to json format.
data/lib/picky/search.rb CHANGED
@@ -61,7 +61,7 @@ module Picky
61
61
  # end
62
62
  #
63
63
  def searching options
64
- @tokenizer = if options.respond_to?(:tokenize)
64
+ @tokenizer = if options.respond_to? :tokenize
65
65
  options
66
66
  else
67
67
  options && Tokenizer.new(options)
@@ -274,13 +274,11 @@ module Picky
274
274
  # Display some nice information for the user.
275
275
  #
276
276
  def to_s
277
- s = "#{self.class}("
278
- ary = []
279
- ary << @indexes.indexes.map(&:name).join(', ') unless @indexes.indexes.empty?
280
- ary << "boosts: #@boosts" if @boosts
281
- s << ary.join(', ')
282
- s << ")"
283
- s
277
+ s = [
278
+ (@indexes.indexes.map(&:name).join(', ') unless @indexes.indexes.empty?),
279
+ ("boosts: #@boosts" if @boosts)
280
+ ].compact
281
+ "#{self.class}(#{s.join(', ')})"
284
282
  end
285
283
 
286
284
  end
@@ -10,7 +10,7 @@ module Picky
10
10
  # Options
11
11
  # counts: Whether you want counts (returns a Hash) or not (returns an Array). (Default true)
12
12
  # at_least: A minimum count a facet needs to have (inclusive). (Default 1)
13
- # filter: A query to filter the facets with.
13
+ # filter: A query to filter the facets with(no_args).
14
14
  #
15
15
  # Usage:
16
16
  # search.facets :name, filter: 'surname:peter', at_least: 2
data/lib/picky.rb CHANGED
@@ -29,8 +29,11 @@ module Picky
29
29
  require 'active_support/multibyte'
30
30
  require 'multi_json'
31
31
  require 'rack_fast_escape' if defined? Rack
32
- require 'fileutils'
33
- require 'strscan'
32
+
33
+ # TODO Still required with Ruby 2.1?
34
+ #
35
+ # require 'fileutils'
36
+ # require 'strscan'
34
37
 
35
38
  # Check if platform specific modifiers need to be installed.
36
39
  #
@@ -98,6 +98,7 @@ describe "OR token" do
98
98
 
99
99
  it { try.search("thing|something|other").ids.should == [1, 2, 3] }
100
100
  it { try.search("something|other").ids.should == [2, 3] }
101
+ it { try.search("other|something").ids.should == [3, 2] }
101
102
  end
102
103
 
103
104
  end
@@ -0,0 +1,57 @@
1
+ # encoding: utf-8
2
+ #
3
+ require 'spec_helper'
4
+
5
+ # Describes how users see often used classes when calling #to_s on them.
6
+ #
7
+ describe 'to_s' do
8
+ describe 'index' do
9
+ it 'shows an index correctly' do
10
+ index = Picky::Index.new :test do
11
+
12
+ end
13
+ index.to_s.should == 'Picky::Index(test, result_id: test)'
14
+ end
15
+ it 'shows an index correctly' do
16
+ index = Picky::Index.new :test do
17
+ category :alli
18
+ end
19
+ index.to_s.should == 'Picky::Index(test, result_id: test, categories: Picky::Categories(Picky::Category(test:alli)))'
20
+ end
21
+ it 'shows an index correctly' do
22
+ index = Picky::Index.new :test do
23
+ source { [1,2,3] }
24
+ category :alli
25
+ end
26
+ index.to_s.should == 'Picky::Index(test, result_id: test, source: [1, 2, 3], categories: Picky::Categories(Picky::Category(test:alli)))'
27
+ end
28
+ it 'shows an index correctly' do
29
+ index = Picky::Index.new :test do
30
+ source { [1,2,3] }
31
+ category :alli
32
+ category :text
33
+ end
34
+ index.to_s.should == 'Picky::Index(test, result_id: test, source: [1, 2, 3], categories: Picky::Categories(Picky::Category(test:alli), Picky::Category(test:text)))'
35
+ end
36
+ end
37
+ describe 'search' do
38
+ it 'shows a search correctly' do
39
+ search = Picky::Search.new
40
+ search.to_s.should == 'Picky::Search(boosts: Picky::Query::Boosts({}))'
41
+ end
42
+ it 'shows a search correctly' do
43
+ search = Picky::Search.new Picky::Index.new(:test)
44
+ search.to_s.should == 'Picky::Search(test, boosts: Picky::Query::Boosts({}))'
45
+ end
46
+ it 'shows a search correctly' do
47
+ search = Picky::Search.new Picky::Index.new(:test), Picky::Index.new(:test2)
48
+ search.to_s.should == 'Picky::Search(test, test2, boosts: Picky::Query::Boosts({}))'
49
+ end
50
+ it 'shows a search correctly' do
51
+ search = Picky::Search.new Picky::Index.new(:test), Picky::Index.new(:test2) do
52
+ boost [:a] => +3
53
+ end
54
+ search.to_s.should == 'Picky::Search(test, test2, boosts: Picky::Query::Boosts({[:a]=>3}))'
55
+ end
56
+ end
57
+ end
@@ -10,7 +10,7 @@ describe Picky::API::Search::Boost do
10
10
  context 'with a Hash' do
11
11
  it 'returns a boosts object' do
12
12
  combinations = [
13
- stub(:combination, :category_name => :bla)
13
+ double(:combination, :category_name => :bla)
14
14
  ]
15
15
 
16
16
  object.extract_boosts([:bla] => +7.77).boost_for(combinations).should == 7.77
@@ -6,9 +6,9 @@ describe Picky::Backends::Backend do
6
6
 
7
7
  # describe 'score' do
8
8
  # it 'forwards to the parameter' do
9
- # combinations = stub :combinations
9
+ # combinations = double :combinations
10
10
  #
11
- # combinations.should_receive(:score).once.with()
11
+ # combinations.should_receive(:score).once.with no_args
12
12
  #
13
13
  # backend.score combinations
14
14
  # end
@@ -9,7 +9,7 @@ describe Picky::Backends::File do
9
9
  # similarity: Picky::Backends::File::Basic.new(:unimportant),
10
10
  # configuration: Picky::Backends::File::Basic.new(:unimportant)
11
11
  #
12
- # @backend.stub! :timed_exclaim
12
+ # @backend.stub :timed_exclaim
13
13
  # end
14
14
  #
15
15
  # describe 'create_...' do
@@ -21,7 +21,7 @@ describe Picky::Backends::File do
21
21
  # ].each do |type, kind|
22
22
  # it "creates and returns a(n) #{type} index" do
23
23
  # @backend.send(:"create_#{type}",
24
- # stub(type, :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}")
24
+ # double(type, :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}")
25
25
  # ).should be_kind_of(kind)
26
26
  # end
27
27
  # end
@@ -32,7 +32,7 @@ describe Picky::Backends::File do
32
32
  before(:each) do
33
33
  @backend = described_class.new
34
34
 
35
- @backend.stub! :timed_exclaim
35
+ @backend.stub :timed_exclaim
36
36
  end
37
37
 
38
38
  describe 'create_...' do
@@ -44,7 +44,7 @@ describe Picky::Backends::File do
44
44
  ].each do |type, kind|
45
45
  it "creates and returns a(n) #{type} index" do
46
46
  @backend.send(:"create_#{type}",
47
- stub(type, :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}")
47
+ double(type, :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}")
48
48
  ).should be_kind_of(kind)
49
49
  end
50
50
  end
@@ -52,50 +52,50 @@ describe Picky::Backends::File do
52
52
 
53
53
  describe "ids" do
54
54
  before(:each) do
55
- @combination1 = stub :combination1
56
- @combination2 = stub :combination2
57
- @combination3 = stub :combination3
55
+ @combination1 = double :combination1
56
+ @combination2 = double :combination2
57
+ @combination3 = double :combination3
58
58
  @combinations = [@combination1, @combination2, @combination3]
59
59
  end
60
60
  it "should intersect correctly" do
61
- @combination1.should_receive(:ids).once.with.and_return (1..100_000).to_a
62
- @combination2.should_receive(:ids).once.with.and_return (1..100).to_a
63
- @combination3.should_receive(:ids).once.with.and_return (1..10).to_a
61
+ @combination1.should_receive(:ids).once.with(no_args).and_return (1..100_000).to_a
62
+ @combination2.should_receive(:ids).once.with(no_args).and_return (1..100).to_a
63
+ @combination3.should_receive(:ids).once.with(no_args).and_return (1..10).to_a
64
64
 
65
65
  @backend.ids(@combinations, :any, :thing).should == (1..10).to_a
66
66
  end
67
67
  it "should intersect symbol_keys correctly" do
68
- @combination1.should_receive(:ids).once.with.and_return (:'00001'..:'10000').to_a
69
- @combination2.should_receive(:ids).once.with.and_return (:'00001'..:'00100').to_a
70
- @combination3.should_receive(:ids).once.with.and_return (:'00001'..:'00010').to_a
68
+ @combination1.should_receive(:ids).once.with(no_args).and_return (:'00001'..:'10000').to_a
69
+ @combination2.should_receive(:ids).once.with(no_args).and_return (:'00001'..:'00100').to_a
70
+ @combination3.should_receive(:ids).once.with(no_args).and_return (:'00001'..:'00010').to_a
71
71
 
72
72
  @backend.ids(@combinations, :any, :thing).should == (:'00001'..:'0010').to_a
73
73
  end
74
74
  it "should intersect correctly when intermediate intersect result is empty" do
75
- @combination1.should_receive(:ids).once.with.and_return (1..100_000).to_a
76
- @combination2.should_receive(:ids).once.with.and_return (11..100).to_a
77
- @combination3.should_receive(:ids).once.with.and_return (1..10).to_a
75
+ @combination1.should_receive(:ids).once.with(no_args).and_return (1..100_000).to_a
76
+ @combination2.should_receive(:ids).once.with(no_args).and_return (11..100).to_a
77
+ @combination3.should_receive(:ids).once.with(no_args).and_return (1..10).to_a
78
78
 
79
79
  @backend.ids(@combinations, :any, :thing).should == []
80
80
  end
81
81
  it "should be fast" do
82
- @combination1.should_receive(:ids).once.with.and_return (1..100_000).to_a
83
- @combination2.should_receive(:ids).once.with.and_return (1..100).to_a
84
- @combination3.should_receive(:ids).once.with.and_return (1..10).to_a
82
+ @combination1.should_receive(:ids).once.with(no_args).and_return (1..100_000).to_a
83
+ @combination2.should_receive(:ids).once.with(no_args).and_return (1..100).to_a
84
+ @combination3.should_receive(:ids).once.with(no_args).and_return (1..10).to_a
85
85
 
86
86
  performance_of { @backend.ids(@combinations, :any, :thing) }.should < 0.004
87
87
  end
88
88
  it "should be fast" do
89
- @combination1.should_receive(:ids).once.with.and_return (1..1000).to_a
90
- @combination2.should_receive(:ids).once.with.and_return (1..100).to_a
91
- @combination3.should_receive(:ids).once.with.and_return (1..10).to_a
89
+ @combination1.should_receive(:ids).once.with(no_args).and_return (1..1000).to_a
90
+ @combination2.should_receive(:ids).once.with(no_args).and_return (1..100).to_a
91
+ @combination3.should_receive(:ids).once.with(no_args).and_return (1..10).to_a
92
92
 
93
93
  performance_of { @backend.ids(@combinations, :any, :thing) }.should < 0.00015
94
94
  end
95
95
  it "should be fast" do
96
- @combination1.should_receive(:ids).once.with.and_return (1..1000).to_a
97
- @combination2.should_receive(:ids).once.with.and_return (901..1000).to_a
98
- @combination3.should_receive(:ids).once.with.and_return (1..10).to_a
96
+ @combination1.should_receive(:ids).once.with(no_args).and_return (1..1000).to_a
97
+ @combination2.should_receive(:ids).once.with(no_args).and_return (901..1000).to_a
98
+ @combination3.should_receive(:ids).once.with(no_args).and_return (1..10).to_a
99
99
 
100
100
  performance_of { @backend.ids(@combinations, :any, :thing) }.should < 0.0001
101
101
  end
@@ -19,7 +19,7 @@ describe Picky::Backends::Memory::JSON do
19
19
 
20
20
  describe "dump" do
21
21
  it "forwards to the given hash" do
22
- hash = stub :hash
22
+ hash = double :hash
23
23
 
24
24
  json.should_receive(:dump_json).once.with hash
25
25
 
@@ -19,7 +19,7 @@ describe Picky::Backends::Memory::Marshal do
19
19
 
20
20
  describe "dump" do
21
21
  it "forwards to the given hash" do
22
- hash = stub :hash
22
+ hash = double :hash
23
23
 
24
24
  marshal.should_receive(:dump_marshal).once.with hash
25
25
 
@@ -9,7 +9,7 @@ describe Picky::Backends::Memory do
9
9
  # similarity: Picky::Backends::Memory::JSON.new(:unimportant),
10
10
  # configuration: Picky::Backends::Memory::Marshal.new(:unimportant)
11
11
  #
12
- # @backend.stub! :timed_exclaim
12
+ # @backend.stub :timed_exclaim
13
13
  # end
14
14
  #
15
15
  # describe 'create_...' do
@@ -21,7 +21,7 @@ describe Picky::Backends::Memory do
21
21
  # ].each do |type, kind|
22
22
  # it "creates and returns a(n) #{type} index" do
23
23
  # @backend.send(:"create_#{type}",
24
- # stub(type, :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}")
24
+ # double(type, :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}")
25
25
  # ).should be_kind_of(kind)
26
26
  # end
27
27
  # end
@@ -35,7 +35,7 @@ describe Picky::Backends::Memory do
35
35
  # similarity: ->(bundle){ Picky::Backends::Memory::JSON.new(bundle.index_path(:similarity)) },
36
36
  # configuration: ->(bundle){ Picky::Backends::Memory::Marshal.new(bundle.index_path(:configuration)) }
37
37
  #
38
- # @backend.stub! :timed_exclaim
38
+ # @backend.stub :timed_exclaim
39
39
  # end
40
40
  #
41
41
  # describe 'create_...' do
@@ -46,8 +46,8 @@ describe Picky::Backends::Memory do
46
46
  # [:configuration, Picky::Backends::Memory::Marshal]
47
47
  # ].each do |type, kind|
48
48
  # it "creates and returns a(n) #{type} index" do
49
- # to_a_able_stub = Object.new
50
- # to_a_able_stub.stub! :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}"
49
+ # to_a_able_double = Object.new
50
+ # to_a_able_stub.stub :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}"
51
51
  # @backend.send(:"create_#{type}", to_a_able_stub).should be_kind_of(kind)
52
52
  # end
53
53
  # end
@@ -58,7 +58,7 @@ describe Picky::Backends::Memory do
58
58
  before(:each) do
59
59
  @backend = described_class.new
60
60
 
61
- @backend.stub! :timed_exclaim
61
+ @backend.stub :timed_exclaim
62
62
  end
63
63
 
64
64
  describe 'create_...' do
@@ -70,7 +70,7 @@ describe Picky::Backends::Memory do
70
70
  ].each do |type, kind|
71
71
  it "creates and returns a(n) #{type} index" do
72
72
  @backend.send(:"create_#{type}",
73
- stub(type, :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}")
73
+ double(type, :index_path => "spec/temp/index/test/some_index/some_category_some_bundle_#{type}")
74
74
  ).should be_kind_of(kind)
75
75
  end
76
76
  end
@@ -78,50 +78,50 @@ describe Picky::Backends::Memory do
78
78
 
79
79
  describe "ids" do
80
80
  before(:each) do
81
- @combination1 = stub :combination1
82
- @combination2 = stub :combination2
83
- @combination3 = stub :combination3
81
+ @combination1 = double :combination1
82
+ @combination2 = double :combination2
83
+ @combination3 = double :combination3
84
84
  @combinations = [@combination1, @combination2, @combination3]
85
85
  end
86
86
  it "should intersect correctly" do
87
- @combination1.should_receive(:ids).once.with.and_return (1..100_000).to_a
88
- @combination2.should_receive(:ids).once.with.and_return (1..100).to_a
89
- @combination3.should_receive(:ids).once.with.and_return (1..10).to_a
87
+ @combination1.should_receive(:ids).once.with(no_args).and_return (1..100_000).to_a
88
+ @combination2.should_receive(:ids).once.with(no_args).and_return (1..100).to_a
89
+ @combination3.should_receive(:ids).once.with(no_args).and_return (1..10).to_a
90
90
 
91
91
  @backend.ids(@combinations, :any, :thing).should == (1..10).to_a
92
92
  end
93
93
  it "should intersect symbol_keys correctly" do
94
- @combination1.should_receive(:ids).once.with.and_return (:'00001'..:'10000').to_a
95
- @combination2.should_receive(:ids).once.with.and_return (:'00001'..:'00100').to_a
96
- @combination3.should_receive(:ids).once.with.and_return (:'00001'..:'00010').to_a
94
+ @combination1.should_receive(:ids).once.with(no_args).and_return (:'00001'..:'10000').to_a
95
+ @combination2.should_receive(:ids).once.with(no_args).and_return (:'00001'..:'00100').to_a
96
+ @combination3.should_receive(:ids).once.with(no_args).and_return (:'00001'..:'00010').to_a
97
97
 
98
98
  @backend.ids(@combinations, :any, :thing).should == (:'00001'..:'0010').to_a
99
99
  end
100
100
  it "should intersect correctly when intermediate intersect result is empty" do
101
- @combination1.should_receive(:ids).once.with.and_return (1..100_000).to_a
102
- @combination2.should_receive(:ids).once.with.and_return (11..100).to_a
103
- @combination3.should_receive(:ids).once.with.and_return (1..10).to_a
101
+ @combination1.should_receive(:ids).once.with(no_args).and_return (1..100_000).to_a
102
+ @combination2.should_receive(:ids).once.with(no_args).and_return (11..100).to_a
103
+ @combination3.should_receive(:ids).once.with(no_args).and_return (1..10).to_a
104
104
 
105
105
  @backend.ids(@combinations, :any, :thing).should == []
106
106
  end
107
107
  it "should be fast" do
108
- @combination1.should_receive(:ids).once.with.and_return (1..100_000).to_a
109
- @combination2.should_receive(:ids).once.with.and_return (1..100).to_a
110
- @combination3.should_receive(:ids).once.with.and_return (1..10).to_a
108
+ @combination1.should_receive(:ids).once.with(no_args).and_return (1..100_000).to_a
109
+ @combination2.should_receive(:ids).once.with(no_args).and_return (1..100).to_a
110
+ @combination3.should_receive(:ids).once.with(no_args).and_return (1..10).to_a
111
111
 
112
112
  performance_of { @backend.ids(@combinations, :any, :thing) }.should < 0.004
113
113
  end
114
114
  it "should be fast" do
115
- @combination1.should_receive(:ids).once.with.and_return (1..1000).to_a
116
- @combination2.should_receive(:ids).once.with.and_return (1..100).to_a
117
- @combination3.should_receive(:ids).once.with.and_return (1..10).to_a
115
+ @combination1.should_receive(:ids).once.with(no_args).and_return (1..1000).to_a
116
+ @combination2.should_receive(:ids).once.with(no_args).and_return (1..100).to_a
117
+ @combination3.should_receive(:ids).once.with(no_args).and_return (1..10).to_a
118
118
 
119
119
  performance_of { @backend.ids(@combinations, :any, :thing) }.should < 0.00015
120
120
  end
121
121
  it "should be fast" do
122
- @combination1.should_receive(:ids).once.with.and_return (1..1000).to_a
123
- @combination2.should_receive(:ids).once.with.and_return (901..1000).to_a
124
- @combination3.should_receive(:ids).once.with.and_return (1..10).to_a
122
+ @combination1.should_receive(:ids).once.with(no_args).and_return (1..1000).to_a
123
+ @combination2.should_receive(:ids).once.with(no_args).and_return (901..1000).to_a
124
+ @combination3.should_receive(:ids).once.with(no_args).and_return (1..10).to_a
125
125
 
126
126
  performance_of { @backend.ids(@combinations, :any, :thing) }.should < 0.0001
127
127
  end
@@ -34,9 +34,9 @@ describe Picky::Backends::Prepared::Text do
34
34
  end
35
35
  describe "retrieve" do
36
36
  before(:each) do
37
- @io = stub :io
38
- @io.should_receive(:each_line).once.with.and_yield '123456,some_nice_token'
39
- ::File.should_receive(:open).any_number_of_times.and_yield @io
37
+ @io = double :io
38
+ @io.should_receive(:each_line).once.with(no_args).and_yield '123456,some_nice_token'
39
+ ::File.should_receive(:open).at_least(1).and_yield @io
40
40
  end
41
41
  it "yields split lines and returns the id and token text" do
42
42
  text.retrieve do |id, token|
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Picky::Backends::Redis::Basic do
4
4
 
5
- let(:client) { stub :client }
5
+ let(:client) { double :client }
6
6
 
7
7
  context 'without options' do
8
8
  let(:backend) { described_class.new client, :some_namespace }
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Picky::Backends::Redis::DirectlyManipulable do
4
4
 
5
- let(:client) { stub :client }
6
- let(:backend) { stub :backend, client: client, namespace: 'some:namespace' }
5
+ let(:client) { double :client }
6
+ let(:backend) { double :backend, client: client, namespace: 'some:namespace' }
7
7
  let(:list) do
8
8
  list = [1,2]
9
9
  described_class.make backend, list, 'some:key'
@@ -24,7 +24,7 @@ describe Picky::Backends::Redis::DirectlyManipulable do
24
24
 
25
25
  context 'stubbed backend' do
26
26
  before(:each) do
27
- backend.stub! :[]
27
+ backend.stub :[]
28
28
  end
29
29
  it 'calls the right client method' do
30
30
  num = described_class.class_variable_get(:@@append_index)
@@ -54,8 +54,8 @@ describe Picky::Backends::Redis::DirectlyManipulable do
54
54
 
55
55
  context 'stubbed client' do
56
56
  before(:each) do
57
- client.stub! :zadd
58
- client.stub! :zrem
57
+ client.stub :zadd
58
+ client.stub :zrem
59
59
  end
60
60
  it 'calls [] at the end of the method' do
61
61
  backend.should_receive(:[]).once.with 'some:key'
@@ -74,9 +74,9 @@ describe Picky::Backends::Redis::DirectlyManipulable do
74
74
 
75
75
  context 'stubbed client/backend' do
76
76
  before(:each) do
77
- backend.stub! :[]
78
- client.stub! :zadd
79
- client.stub! :zrem
77
+ backend.stub :[]
78
+ client.stub :zadd
79
+ client.stub :zrem
80
80
  end
81
81
  it 'behaves like an ordinary Array' do
82
82
  list << 3
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Picky::Backends::Redis::Float do
4
4
 
5
- let(:client) { stub :client }
5
+ let(:client) { double :client }
6
6
  let(:backend) { described_class.new client, 'some_namespace' }
7
7
 
8
8
  describe 'dump' do
@@ -23,12 +23,12 @@ describe Picky::Backends::Redis::Float do
23
23
  backend['some']
24
24
  end
25
25
  it 'returns whatever it gets from the backend' do
26
- client.should_receive(:hget).any_number_of_times.and_return '1.23'
26
+ client.should_receive(:hget).at_least(1).and_return '1.23'
27
27
 
28
28
  backend['anything'].should == 1.23
29
29
  end
30
30
  it 'returns whatever it gets from the backend' do
31
- client.should_receive(:hget).any_number_of_times.and_return nil
31
+ client.should_receive(:hget).at_least(1).and_return nil
32
32
 
33
33
  backend['anything'].should == nil
34
34
  end
@@ -2,12 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  describe Picky::Backends::Redis::List do
4
4
 
5
- let(:client) { stub :client }
5
+ let(:client) { double :client }
6
6
  let(:index) { described_class.new client, :some_namespace }
7
7
 
8
8
  describe '[]' do
9
9
  it 'returns whatever comes back from the backend' do
10
- client.stub! :zrange => [:some_lrange_result]
10
+ client.stub :zrange => [:some_lrange_result]
11
11
 
12
12
  index[:anything].should == [:some_lrange_result]
13
13
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Picky::Backends::Redis::String do
4
4
 
5
- let(:client) { stub :client }
5
+ let(:client) { double :client }
6
6
  let(:backend) { described_class.new client, :some_namespace }
7
7
 
8
8
  describe 'dump' do
@@ -23,7 +23,7 @@ describe Picky::Backends::Redis::String do
23
23
  backend[:some_symbol]
24
24
  end
25
25
  it 'returns whatever it gets from the backend' do
26
- client.should_receive(:hget).any_number_of_times.and_return :some_result
26
+ client.should_receive(:hget).at_least(1).and_return :some_result
27
27
 
28
28
  backend[:anything].should == :some_result
29
29
  end