picky 3.5.4 → 3.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 (57) hide show
  1. data/lib/picky/backends/backend.rb +1 -1
  2. data/lib/picky/backends/file/basic.rb +0 -36
  3. data/lib/picky/backends/file/json.rb +1 -1
  4. data/lib/picky/backends/file.rb +4 -4
  5. data/lib/picky/backends/helpers/file.rb +0 -26
  6. data/lib/picky/backends/memory/basic.rb +0 -35
  7. data/lib/picky/backends/memory.rb +4 -4
  8. data/lib/picky/backends/redis/basic.rb +0 -33
  9. data/lib/picky/backends/redis.rb +4 -4
  10. data/lib/picky/backends/sqlite/db.rb +84 -0
  11. data/lib/picky/backends/sqlite.rb +75 -0
  12. data/lib/picky/bundle.rb +15 -87
  13. data/lib/picky/bundle_realtime.rb +1 -1
  14. data/lib/picky/categories.rb +1 -0
  15. data/lib/picky/categories_indexed.rb +1 -1
  16. data/lib/picky/categories_indexing.rb +1 -3
  17. data/lib/picky/category.rb +16 -2
  18. data/lib/picky/category_indexed.rb +5 -3
  19. data/lib/picky/category_indexing.rb +0 -26
  20. data/lib/picky/category_realtime.rb +2 -0
  21. data/lib/picky/extensions/string.rb +20 -0
  22. data/lib/picky/extensions/symbol.rb +22 -0
  23. data/lib/picky/generators/similarity/double_metaphone.rb +1 -2
  24. data/lib/picky/generators/similarity/metaphone.rb +1 -2
  25. data/lib/picky/generators/similarity/phonetic.rb +0 -10
  26. data/lib/picky/generators/similarity/soundex.rb +1 -2
  27. data/lib/picky/index.rb +9 -2
  28. data/lib/picky/index_indexed.rb +4 -4
  29. data/lib/picky/index_indexing.rb +1 -5
  30. data/lib/picky/indexes_indexed.rb +7 -6
  31. data/lib/picky/indexes_indexing.rb +1 -7
  32. data/lib/picky/loader.rb +4 -1
  33. data/lib/picky/sources/couch.rb +1 -1
  34. data/lib/picky/sources/mongo.rb +1 -1
  35. data/lib/picky/wrappers/bundle/calculation.rb +1 -1
  36. data/lib/picky/wrappers/bundle/exact_partial.rb +3 -12
  37. data/lib/picky/wrappers/bundle/location.rb +1 -0
  38. data/lib/tasks/index.rake +0 -4
  39. data/spec/lib/backends/file/basic_spec.rb +5 -17
  40. data/spec/lib/backends/memory/basic_spec.rb +5 -17
  41. data/spec/lib/backends/redis/basic_spec.rb +5 -52
  42. data/spec/lib/backends/sqlite/db_spec.rb +80 -0
  43. data/spec/lib/backends/sqlite_spec.rb +131 -0
  44. data/spec/lib/category_indexed_spec.rb +2 -2
  45. data/spec/lib/category_indexing_spec.rb +0 -24
  46. data/spec/lib/extensions/string_spec.rb +16 -0
  47. data/spec/lib/extensions/symbol_spec.rb +16 -0
  48. data/spec/lib/index_indexed_spec.rb +16 -16
  49. data/spec/lib/indexes_indexed_spec.rb +13 -7
  50. data/spec/lib/indexes_indexing_spec.rb +3 -6
  51. data/spec/lib/indexing/bundle_spec.rb +6 -125
  52. data/spec/lib/sources/couch_spec.rb +8 -8
  53. data/spec/lib/sources/mongo_spec.rb +5 -5
  54. data/spec/specific/realtime_spec.rb +397 -173
  55. metadata +44 -29
  56. data/lib/picky/bundling.rb +0 -10
  57. data/lib/tasks/checks.rake +0 -13
@@ -0,0 +1,131 @@
1
+ require 'spec_helper'
2
+
3
+ describe Picky::Backends::Sqlite do
4
+
5
+ context 'with options' do
6
+ before(:each) do
7
+ @backend = described_class.new inverted: Picky::Backends::Sqlite::DB.new(:unimportant),
8
+ weights: Picky::Backends::Sqlite::DB.new(:unimportant),
9
+ similarity: Picky::Backends::Sqlite::DB.new(:unimportant),
10
+ configuration: Picky::Backends::Sqlite::DB.new(:unimportant)
11
+
12
+ @backend.stub! :timed_exclaim
13
+ end
14
+
15
+ describe 'create_...' do
16
+ [
17
+ [:inverted, Picky::Backends::Sqlite::DB],
18
+ [:weights, Picky::Backends::Sqlite::DB],
19
+ [:similarity, Picky::Backends::Sqlite::DB],
20
+ [:configuration, Picky::Backends::Sqlite::DB]
21
+ ].each do |type, kind|
22
+ it "creates and returns a(n) #{type} index" do
23
+ @backend.send(:"create_#{type}",
24
+ stub(type, :index_path => "spec/test_directory/index/test/some_index/some_category_some_bundle_#{type}")
25
+ ).should be_kind_of(kind)
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ context 'with lambda options' do
32
+ before(:each) do
33
+ @backend = described_class.new inverted: ->(bundle){ Picky::Backends::Sqlite::DB.new(bundle.index_path(:inverted)) },
34
+ weights: ->(bundle){ Picky::Backends::Sqlite::DB.new(bundle.index_path(:weights)) },
35
+ similarity: ->(bundle){ Picky::Backends::Sqlite::DB.new(bundle.index_path(:similarity)) },
36
+ configuration: ->(bundle){ Picky::Backends::Sqlite::DB.new(bundle.index_path(:configuration)) }
37
+
38
+ @backend.stub! :timed_exclaim
39
+ end
40
+
41
+ describe 'create_...' do
42
+ [
43
+ [:inverted, Picky::Backends::Sqlite::DB],
44
+ [:weights, Picky::Backends::Sqlite::DB],
45
+ [:similarity, Picky::Backends::Sqlite::DB],
46
+ [:configuration, Picky::Backends::Sqlite::DB]
47
+ ].each do |type, kind|
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/test_directory/index/test/some_index/some_category_some_bundle_#{type}"
51
+ @backend.send(:"create_#{type}", to_a_able_stub).should be_kind_of(kind)
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ context 'without options' do
58
+ before(:each) do
59
+ @backend = described_class.new
60
+
61
+ @backend.stub! :timed_exclaim
62
+ end
63
+
64
+ describe 'create_...' do
65
+ [
66
+ [:inverted, Picky::Backends::Sqlite::DB],
67
+ [:weights, Picky::Backends::Sqlite::DB],
68
+ [:similarity, Picky::Backends::Sqlite::DB],
69
+ [:configuration, Picky::Backends::Sqlite::DB]
70
+ ].each do |type, kind|
71
+ it "creates and returns a(n) #{type} index" do
72
+ @backend.send(:"create_#{type}",
73
+ stub(type, :index_path => "spec/test_directory/index/test/some_index/some_category_some_bundle_#{type}")
74
+ ).should be_kind_of(kind)
75
+ end
76
+ end
77
+ end
78
+
79
+ describe "ids" do
80
+ before(:each) do
81
+ @combination1 = stub :combination1
82
+ @combination2 = stub :combination2
83
+ @combination3 = stub :combination3
84
+ @combinations = [@combination1, @combination2, @combination3]
85
+ end
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
90
+
91
+ @backend.ids(@combinations, :any, :thing).should == (1..10).to_a
92
+ end
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
97
+
98
+ @backend.ids(@combinations, :any, :thing).should == (:'00001'..:'0010').to_a
99
+ end
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
104
+
105
+ @backend.ids(@combinations, :any, :thing).should == []
106
+ end
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
111
+
112
+ performance_of { @backend.ids(@combinations, :any, :thing) }.should < 0.004
113
+ end
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
118
+
119
+ performance_of { @backend.ids(@combinations, :any, :thing) }.should < 0.00015
120
+ end
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
125
+
126
+ performance_of { @backend.ids(@combinations, :any, :thing) }.should < 0.0001
127
+ end
128
+ end
129
+ end
130
+
131
+ end
@@ -158,13 +158,13 @@ describe Picky::Category do
158
158
  end
159
159
  end
160
160
 
161
- describe 'load_from_cache' do
161
+ describe 'load' do
162
162
  it 'should call two methods' do
163
163
  @category.should_receive(:clear_realtime_mapping).once
164
164
  @exact.should_receive(:load).once
165
165
  @partial.should_receive(:load).once
166
166
 
167
- @category.load_from_cache
167
+ @category.load
168
168
  end
169
169
  end
170
170
  end
@@ -12,30 +12,6 @@ describe Picky::Category do
12
12
  let(:exact) { category.exact }
13
13
  let(:partial) { category.partial }
14
14
 
15
- describe 'backup' do
16
- it 'delegates to both bundles' do
17
- exact.should_receive(:backup).once.with()
18
- partial.should_receive(:backup).once.with()
19
-
20
- category.backup
21
- end
22
- end
23
- describe 'restore' do
24
- it 'delegates to both bundles' do
25
- exact.should_receive(:restore).once.with()
26
- partial.should_receive(:restore).once.with()
27
-
28
- category.restore
29
- end
30
- end
31
- describe 'check' do
32
- it 'delegates to both bundles' do
33
- exact.should_receive(:raise_unless_cache_exists).once.with()
34
- partial.should_receive(:raise_unless_cache_exists).once.with()
35
-
36
- category.check
37
- end
38
- end
39
15
  describe 'clear' do
40
16
  it 'delegates to both bundles' do
41
17
  exact.should_receive(:delete).once.with()
@@ -17,6 +17,22 @@ describe String do
17
17
  end
18
18
  end
19
19
 
20
+ describe 'double_metaphone' do
21
+ it 'returns the right code' do
22
+ 'hello'.double_metaphone.should == 'HL'
23
+ end
24
+ end
25
+ describe 'metaphone' do
26
+ it 'returns the right code' do
27
+ 'hello'.metaphone.should == 'HL'
28
+ end
29
+ end
30
+ describe 'soundex' do
31
+ it 'returns the right code' do
32
+ 'hello'.soundex.should == 'H400'
33
+ end
34
+ end
35
+
20
36
  describe 'each_intoken' do
21
37
  context 'normal String' do
22
38
  before(:each) do
@@ -17,6 +17,22 @@ describe Symbol do
17
17
  end
18
18
  end
19
19
 
20
+ describe 'double_metaphone' do
21
+ it 'returns the right code' do
22
+ :hello.double_metaphone.should == :HL
23
+ end
24
+ end
25
+ describe 'metaphone' do
26
+ it 'returns the right code' do
27
+ :hello.metaphone.should == :HL
28
+ end
29
+ end
30
+ describe 'soundex' do
31
+ it 'returns the right code' do
32
+ :hello.soundex.should == :H400
33
+ end
34
+ end
35
+
20
36
  describe 'each_intoken' do
21
37
  context 'normal symbol' do
22
38
  before(:each) do
@@ -1,51 +1,51 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Picky::Index do
4
-
4
+
5
5
  context 'without stubbed categories' do
6
6
  before(:each) do
7
7
  @index = described_class.new :some_index_name
8
8
  end
9
-
9
+
10
10
  describe 'define_category' do
11
11
  it 'adds a new category to the categories' do
12
12
  @index.define_category :some_category_name
13
-
14
- @index.categories.categories.size.should == 1
13
+
14
+ @index.categories.categories.size.should == 1
15
15
  end
16
16
  it 'returns the new category' do
17
17
  @index.define_category(:some_category_name).should be_kind_of(Picky::Category)
18
18
  end
19
19
  end
20
20
  end
21
-
21
+
22
22
  context "with stubbed categories" do
23
23
  before(:each) do
24
24
  @categories = stub :categories
25
-
25
+
26
26
  @index = described_class.new :some_name
27
27
  @index.define_category :some_category_name1
28
28
  @index.define_category :some_category_name2
29
-
29
+
30
30
  @index.stub! :categories => @categories
31
31
  end
32
-
33
- describe "load_from_cache" do
32
+
33
+ describe "load" do
34
34
  it "delegates to each category" do
35
- @categories.should_receive(:load_from_cache).once.with
36
-
37
- @index.load_from_cache
35
+ @categories.should_receive(:load).once.with
36
+
37
+ @index.load
38
38
  end
39
39
  end
40
40
  describe "possible_combinations" do
41
41
  it "delegates to the combinator" do
42
42
  @categories.should_receive(:possible_combinations).once.with :some_token
43
-
43
+
44
44
  @index.possible_combinations :some_token
45
45
  end
46
46
  end
47
47
  end
48
-
48
+
49
49
  context 'result_identifier' do
50
50
  context 'with it set' do
51
51
  let(:index) do
@@ -67,11 +67,11 @@ describe Picky::Index do
67
67
  end
68
68
  end
69
69
  end
70
-
70
+
71
71
  context "no categories" do
72
72
  it "works" do
73
73
  described_class.new :some_name
74
74
  end
75
75
  end
76
-
76
+
77
77
  end
@@ -11,7 +11,7 @@ describe Picky::Indexes do
11
11
  indexes.indexes.should == []
12
12
  end
13
13
  end
14
-
14
+
15
15
  describe 'methods' do
16
16
  let(:indexes) { described_class.new }
17
17
  before(:each) do
@@ -39,23 +39,29 @@ describe Picky::Indexes do
39
39
  describe 'clear' do
40
40
  it 'clears the indexes' do
41
41
  indexes.clear_indexes
42
-
42
+
43
43
  indexes.indexes.should == []
44
44
  end
45
45
  it 'clears the mapping' do
46
46
  indexes.clear_indexes
47
-
47
+
48
48
  indexes.index_mapping.should == {}
49
49
  end
50
50
  end
51
51
  describe 'reload' do
52
- it 'calls load_from_cache on each in order' do
53
- @index1.should_receive(:load_from_cache).once.with.ordered
54
- @index2.should_receive(:load_from_cache).once.with.ordered
52
+ it 'calls load on each in order' do
53
+ @index1.should_receive(:reload).once.with.ordered
54
+ @index2.should_receive(:reload).once.with.ordered
55
55
 
56
56
  indexes.reload
57
57
  end
58
+ it 'is aliased' do
59
+ @index1.should_receive(:load).once.with.ordered
60
+ @index2.should_receive(:load).once.with.ordered
61
+
62
+ indexes.load
63
+ end
58
64
  end
59
65
  end
60
-
66
+
61
67
  end
@@ -23,7 +23,7 @@ describe Picky::Indexes do
23
23
  it 'takes a snapshot, then indexes and caches each' do
24
24
  @index1.should_receive(:index).once.with.ordered
25
25
  @index2.should_receive(:index).once.with.ordered
26
-
26
+
27
27
  indexes.index_for_tests
28
28
  end
29
29
  end
@@ -35,7 +35,7 @@ describe Picky::Indexes do
35
35
  describe 'clear_indexes' do
36
36
  it 'clears the indexes' do
37
37
  indexes.clear_indexes
38
-
38
+
39
39
  indexes.indexes.should == []
40
40
  end
41
41
  end
@@ -49,10 +49,7 @@ describe Picky::Indexes do
49
49
  end
50
50
  end
51
51
  end
52
- it_delegates_each :check
53
52
  it_delegates_each :clear
54
- it_delegates_each :backup
55
- it_delegates_each :restore
56
53
  end
57
-
54
+
58
55
  end
@@ -35,22 +35,6 @@ describe Picky::Bundle do
35
35
  end
36
36
  end
37
37
 
38
- describe 'raise_cache_missing' do
39
- it 'does something' do
40
- expect {
41
- bundle.raise_cache_missing :similarity
42
- }.to raise_error("Error: The similarity cache for some_index:some_category:some_name is missing.")
43
- end
44
- end
45
-
46
- describe 'warn_cache_small' do
47
- it 'warns the user' do
48
- bundle.should_receive(:warn).once.with "Warning: similarity cache for some_index:some_category:some_name smaller than 16 bytes."
49
-
50
- bundle.warn_cache_small :similarity
51
- end
52
- end
53
-
54
38
  describe 'identifier' do
55
39
  it 'should return a specific identifier' do
56
40
  bundle.identifier.should == 'some_index:some_category:some_name'
@@ -70,110 +54,7 @@ describe Picky::Bundle do
70
54
  end
71
55
  end
72
56
 
73
- describe 'raise_unless_cache_exists' do
74
- it "calls methods in order" do
75
- bundle.should_receive(:raise_unless_index_exists).once.ordered
76
- bundle.should_receive(:raise_unless_similarity_exists).once.ordered
77
-
78
- bundle.raise_unless_cache_exists
79
- end
80
- end
81
- describe 'raise_unless_index_exists' do
82
- context 'partial strategy saved' do
83
- before(:each) do
84
- strategy = stub :strategy, :saved? => true
85
- bundle.stub! :partial_strategy => strategy
86
- end
87
- it "calls the methods in order" do
88
- bundle.should_receive(:warn_if_index_small).once.ordered
89
- bundle.should_receive(:raise_unless_index_ok).once.ordered
90
-
91
- bundle.raise_unless_index_exists
92
- end
93
- end
94
- context 'partial strategy not saved' do
95
- before(:each) do
96
- strategy = stub :strategy, :saved? => false
97
- bundle.stub! :partial_strategy => strategy
98
- end
99
- it "calls nothing" do
100
- bundle.should_receive(:warn_if_index_small).never
101
- bundle.should_receive(:raise_unless_index_ok).never
102
-
103
- bundle.raise_unless_index_exists
104
- end
105
- end
106
- end
107
- describe 'raise_unless_similarity_exists' do
108
- context 'similarity strategy saved' do
109
- before(:each) do
110
- strategy = stub :strategy, :saved? => true
111
- bundle.stub! :similarity_strategy => strategy
112
- end
113
- it "calls the methods in order" do
114
- bundle.should_receive(:warn_if_similarity_small).once.ordered
115
- bundle.should_receive(:raise_unless_similarity_ok).once.ordered
116
57
 
117
- bundle.raise_unless_similarity_exists
118
- end
119
- end
120
- context 'similarity strategy not saved' do
121
- before(:each) do
122
- strategy = stub :strategy, :saved? => false
123
- bundle.stub! :similarity_strategy => strategy
124
- end
125
- it "calls nothing" do
126
- bundle.should_receive(:warn_if_similarity_small).never
127
- bundle.should_receive(:raise_unless_similarity_ok).never
128
-
129
- bundle.raise_unless_similarity_exists
130
- end
131
- end
132
- end
133
- describe 'warn_if_similarity_small' do
134
- context "files similarity cache small" do
135
- before(:each) do
136
- bundle.stub! :backend_similarity => stub(:backend_similarity, :cache_small? => true)
137
- end
138
- it "warns" do
139
- bundle.should_receive(:warn_cache_small).once.with :similarity
140
-
141
- bundle.warn_if_similarity_small
142
- end
143
- end
144
- context "files similarity cache not small" do
145
- before(:each) do
146
- bundle.stub! :backend_similarity => stub(:backend_similarity, :cache_small? => false)
147
- end
148
- it "does not warn" do
149
- bundle.should_receive(:warn_cache_small).never
150
-
151
- bundle.warn_if_similarity_small
152
- end
153
- end
154
- end
155
- describe 'raise_unless_similarity_ok' do
156
- context "files similarity cache ok" do
157
- before(:each) do
158
- bundle.stub! :backend_similarity => stub(:backend_similarity, :cache_ok? => true)
159
- end
160
- it "warns" do
161
- bundle.should_receive(:raise_cache_missing).never
162
-
163
- bundle.raise_unless_similarity_ok
164
- end
165
- end
166
- context "files similarity cache not ok" do
167
- before(:each) do
168
- bundle.stub! :backend_similarity => stub(:backend_similarity, :cache_ok? => false)
169
- end
170
- it "does not warn" do
171
- bundle.should_receive(:raise_cache_missing).once.with :similarity
172
-
173
- bundle.raise_unless_similarity_ok
174
- end
175
- end
176
- end
177
58
 
178
59
  describe 'initialization' do
179
60
  it 'should initialize the index correctly' do
@@ -188,12 +69,12 @@ describe Picky::Bundle do
188
69
  it 'should initialize the configuration correctly' do
189
70
  bundle.configuration.should == {}
190
71
  end
191
- # it 'should initialize the partial strategy correctly' do
192
- # bundle.partial_strategy.should == @partial
193
- # end
194
- # it 'should initialize the weights strategy correctly' do
195
- # bundle.weights_strategy.should == @weights
196
- # end
72
+ it 'should initialize the partial strategy correctly' do
73
+ bundle.partial_strategy.should == :some_partial
74
+ end
75
+ it 'should initialize the weights strategy correctly' do
76
+ bundle.weights_strategy.should == @weights
77
+ end
197
78
  it 'should initialize the similarity strategy correctly' do
198
79
  bundle.similarity_strategy.should == @similarity
199
80
  end
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Picky::Sources::Couch do
4
-
4
+
5
5
  describe 'key_format' do
6
6
  context 'default' do
7
7
  let(:source) { described_class.new(:a, :b, url: 'bla') }
8
8
  it 'is correct' do
9
- source.key_format.should == :to_sym
9
+ source.key_format.should == :to_s
10
10
  end
11
11
  end
12
12
  context 'non-default' do
@@ -16,14 +16,14 @@ describe Picky::Sources::Couch do
16
16
  end
17
17
  end
18
18
  end
19
-
19
+
20
20
  describe 'to_s' do
21
21
  let(:source) { described_class.new(:a, :b, :url => 'bla') }
22
22
  it 'is correct' do
23
23
  source.to_s.should == 'Picky::Sources::Couch'
24
24
  end
25
25
  end
26
-
26
+
27
27
  describe 'special keys' do
28
28
  context 'uuid keys' do
29
29
  context "with database" do
@@ -36,7 +36,7 @@ describe Picky::Sources::Couch do
36
36
  it "yields the right data" do
37
37
  category = stub :b, :from => :b
38
38
  @source.harvest category do |id, token|
39
- id.should eql('550e8400-e29b-41d4-a716-446655440000')
39
+ id.should eql('550e8400-e29b-41d4-a716-446655440000')
40
40
  token.should eql('b data')
41
41
  end.should have(1).item
42
42
  end
@@ -62,7 +62,7 @@ describe Picky::Sources::Couch do
62
62
  it "yields the right data" do
63
63
  category = stub :b, :from => :b
64
64
  @source.harvest category do |id, token|
65
- id.should eql('123')
65
+ id.should eql('123')
66
66
  token.should eql('b data')
67
67
  end.should have(1).item
68
68
  end
@@ -78,7 +78,7 @@ describe Picky::Sources::Couch do
78
78
  end
79
79
  end
80
80
  end
81
-
81
+
82
82
  context 'default keys' do
83
83
  context "without database" do
84
84
  it "should fail correctly" do
@@ -96,7 +96,7 @@ describe Picky::Sources::Couch do
96
96
  it "yields the right data" do
97
97
  category = stub :b, :from => :b
98
98
  @source.harvest category do |id, token|
99
- id.should eql('7f')
99
+ id.should eql('7f')
100
100
  token.should eql('b data')
101
101
  end.should have(1).item
102
102
  end
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Picky::Sources::Mongo do
4
-
4
+
5
5
  describe 'key_format' do
6
6
  context 'default' do
7
7
  let(:source) { described_class.new(:a, :b, :url => 'someurl', :db => 'somedb') }
8
8
  it 'is correct' do
9
- source.key_format.should == :to_sym
9
+ source.key_format.should == :to_s
10
10
  end
11
11
  end
12
12
 
@@ -17,14 +17,14 @@ describe Picky::Sources::Mongo do
17
17
  end
18
18
  end
19
19
  end
20
-
20
+
21
21
  describe 'to_s' do
22
22
  let(:source) { described_class.new(:a, :b, :url => 'someurl', :db => 'somedb') }
23
23
  it 'is correct' do
24
24
  source.to_s.should == 'Picky::Sources::Mongo'
25
25
  end
26
26
  end
27
-
27
+
28
28
  context "without database" do
29
29
  it "should fail correctly" do
30
30
  lambda { @source = described_class.new(:a, :b, :url => 'someurl') }.should raise_error(described_class::NoDBGiven)
@@ -41,7 +41,7 @@ describe Picky::Sources::Mongo do
41
41
  it "yields the right data" do
42
42
  category = stub :b, :from => :b, :index_name => :some_index_name
43
43
  @source.harvest category do |id, token|
44
- id.should eql('7f')
44
+ id.should eql('7f')
45
45
  token.should eql('b data')
46
46
  end.should have(1).item
47
47
  end