Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 131 lines (113 sloc) 4.23 kb
bce7983 @floere + qualifiers options -> qualifiers, qualifier, default:name
authored
1 require 'spec_helper'
ba87268 @floere + big rewrite
authored
2
dc95141 @floere + Namespacing in tests
authored
3 describe Picky::Category do
c6d3d26 @floere + dumping indexes during runtime is possible now
authored
4
ba87268 @floere + big rewrite
authored
5 before(:each) do
7a0185c @floere + rewrote index/backend handling, pass in backend through index optio…
authored
6 @index = Picky::Index.new :some_index
c6559b7 @floere Rename stub to double.
authored
7 @source = double :some_given_source, :each => nil
ba87268 @floere + big rewrite
authored
8 end
7a91512 @floere + Replace mock with stub.
authored
9 let(:category) { described_class.new(:some_category, @index, :source => @source).tap { |c| c.stub :timed_exclaim } }
c6d3d26 @floere + dumping indexes during runtime is possible now
authored
10
bce7983 @floere + qualifiers options -> qualifiers, qualifier, default:name
authored
11 context "unit specs" do
3c57694 @floere + huge rewrite of index bundles
authored
12 let(:exact) { category.exact }
13 let(:partial) { category.partial }
c6d3d26 @floere + dumping indexes during runtime is possible now
authored
14
08814eb @floere ! specs
authored
15 describe 'clear' do
0f7ec55 @floere - active_support/delegation
authored
16 it 'forwards to both bundles' do
239d898 @floere + Move to RSpec 3 finished.
authored
17 exact.should_receive(:clear).once.with no_args
18 partial.should_receive(:clear).once.with no_args
c6d3d26 @floere + dumping indexes during runtime is possible now
authored
19
08814eb @floere ! specs
authored
20 category.clear
a898040 @floere + category delegation specs
authored
21 end
22 end
c6d3d26 @floere + dumping indexes during runtime is possible now
authored
23
24 describe 'dump' do
fe3bfa9 @floere + category, + type
authored
25 before(:each) do
7a91512 @floere + Replace mock with stub.
authored
26 exact.stub :dump
27 partial.stub :dump
fe3bfa9 @floere + category, + type
authored
28 end
29 it 'should dump the exact index' do
239d898 @floere + Move to RSpec 3 finished.
authored
30 exact.should_receive(:dump).once.with no_args
fe3bfa9 @floere + category, + type
authored
31
c6d3d26 @floere + dumping indexes during runtime is possible now
authored
32 category.dump
fe3bfa9 @floere + category, + type
authored
33 end
34 it 'should dump the partial index' do
239d898 @floere + Move to RSpec 3 finished.
authored
35 partial.should_receive(:dump).once.with no_args
fe3bfa9 @floere + category, + type
authored
36
c6d3d26 @floere + dumping indexes during runtime is possible now
authored
37 category.dump
fe3bfa9 @floere + category, + type
authored
38 end
39 end
c6d3d26 @floere + dumping indexes during runtime is possible now
authored
40
78190c1 @floere + complete rewrite of indexing/snapshotting/connecting
authored
41 describe 'cache' do
fe3bfa9 @floere + category, + type
authored
42 it 'should call multiple methods in order' do
239d898 @floere + Move to RSpec 3 finished.
authored
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
c6d3d26 @floere + dumping indexes during runtime is possible now
authored
46
78190c1 @floere + complete rewrite of indexing/snapshotting/connecting
authored
47 category.cache
fe3bfa9 @floere + category, + type
authored
48 end
49 end
c6d3d26 @floere + dumping indexes during runtime is possible now
authored
50
0a65aa5 @floere ! specs
authored
51 describe 'retrieve' do
52 it 'call the right thing' do
c6559b7 @floere Rename stub to double.
authored
53 prepared = double :prepared
c5c9770 @floere + Replace stub with double. Replace any_number_of_times with at_least…
authored
54 prepared.should_receive(:retrieve).at_least(1)
0a65aa5 @floere ! specs
authored
55 .and_yield(1, :some_token)
56 .and_yield(2, :some_token)
57 .and_yield(3, :some_token)
58 .and_yield(4, :some_token)
59 .and_yield(5, :some_token)
7a91512 @floere + Replace mock with stub.
authored
60 category.stub :prepared => prepared
0a65aa5 @floere ! specs
authored
61
b951f72 @floere + Experimental Index#static option.
authored
62 category.should_receive(:add_tokenized_token).once.with(1, :some_token, :<<, nil, nil)
63 category.should_receive(:add_tokenized_token).once.with(2, :some_token, :<<, nil, nil)
64 category.should_receive(:add_tokenized_token).once.with(3, :some_token, :<<, nil, nil)
65 category.should_receive(:add_tokenized_token).once.with(4, :some_token, :<<, nil, nil)
66 category.should_receive(:add_tokenized_token).once.with(5, :some_token, :<<, nil, nil)
0a65aa5 @floere ! specs
authored
67
68 category.retrieve
69 end
70 end
71
dc2ce6e @floere + key_format option for both index and categories, source overrides c…
authored
72 describe 'key_format' do
6610135 @floere + tokenizer, character substituter, source API extracted and made exp…
authored
73 context 'category has its own key_format' do
dc2ce6e @floere + key_format option for both index and categories, source overrides c…
authored
74 before(:each) do
6610135 @floere + tokenizer, character substituter, source API extracted and made exp…
authored
75 category.instance_variable_set :@key_format, :other_key_format
dc2ce6e @floere + key_format option for both index and categories, source overrides c…
authored
76 end
77 it 'returns that key_format' do
6610135 @floere + tokenizer, character substituter, source API extracted and made exp…
authored
78 category.key_format.should == :other_key_format
dc2ce6e @floere + key_format option for both index and categories, source overrides c…
authored
79 end
80 end
6610135 @floere + tokenizer, character substituter, source API extracted and made exp…
authored
81 context 'category does not have its own key format' do
dc2ce6e @floere + key_format option for both index and categories, source overrides c…
authored
82 before(:each) do
6610135 @floere + tokenizer, character substituter, source API extracted and made exp…
authored
83 category.instance_variable_set :@key_format, nil
dc2ce6e @floere + key_format option for both index and categories, source overrides c…
authored
84 end
6610135 @floere + tokenizer, character substituter, source API extracted and made exp…
authored
85 context 'it has an index' do
dc2ce6e @floere + key_format option for both index and categories, source overrides c…
authored
86 before(:each) do
c5c9770 @floere + Replace stub with double. Replace any_number_of_times with at_least…
authored
87 category.instance_variable_set :@index, double(:index, :key_format => :yet_another_key_format)
dc2ce6e @floere + key_format option for both index and categories, source overrides c…
authored
88 end
89 it 'returns that key_format' do
6610135 @floere + tokenizer, character substituter, source API extracted and made exp…
authored
90 category.key_format.should == :yet_another_key_format
dc2ce6e @floere + key_format option for both index and categories, source overrides c…
authored
91 end
92 end
93 end
94 end
c6d3d26 @floere + dumping indexes during runtime is possible now
authored
95
f1f1fe0 @floere + big elegantifying rewrite (again)
authored
96 describe 'source' do
97 context 'with explicit source' do
6610135 @floere + tokenizer, character substituter, source API extracted and made exp…
authored
98 let(:category) { described_class.new(:some_category, @index, :source => [1]) }
f1f1fe0 @floere + big elegantifying rewrite (again)
authored
99 it 'returns the right source' do
6610135 @floere + tokenizer, character substituter, source API extracted and made exp…
authored
100 category.source.should == [1]
f1f1fe0 @floere + big elegantifying rewrite (again)
authored
101 end
102 end
103 context 'without explicit source' do
7a91512 @floere + Replace mock with stub.
authored
104 let(:category) { described_class.new(:some_category, @index.tap{ |index| index.stub :source => :index_source }) }
f1f1fe0 @floere + big elegantifying rewrite (again)
authored
105 it 'returns the right source' do
106 category.source.should == :index_source
107 end
108 end
109 end
c6d3d26 @floere + dumping indexes during runtime is possible now
authored
110
a5da40f @floere + query base, field specs
authored
111 describe "index" do
112 before(:each) do
c6559b7 @floere Rename stub to double.
authored
113 @indexer = double :indexer, :index => nil
7a91512 @floere + Replace mock with stub.
authored
114 category.stub :indexer => @indexer
a5da40f @floere + query base, field specs
authored
115 end
116 it "tells the indexer to index" do
79a9c0c @floere + history, + 4.0.0-pre1, + parallel indexing
authored
117 @indexer.should_receive(:prepare).once
c6d3d26 @floere + dumping indexes during runtime is possible now
authored
118
5f75fbc @floere + Rename: + #index! -> #prepare (data), + #cache! -> #cache (prepared…
authored
119 category.prepare
a5da40f @floere + query base, field specs
authored
120 end
121 end
24266d8 @floere + field config spec
authored
122 describe "source" do
123 context "without source" do
252bcf3 @floere + clarifications, ! spec to lazy indexer creation
authored
124 it "has no problem with that" do
125 lambda { described_class.new :some_name, @index }.should_not raise_error
bce7983 @floere + qualifiers options -> qualifiers, qualifier, default:name
authored
126 end
127 end
128 end
129 end
c6d3d26 @floere + dumping indexes during runtime is possible now
authored
130
bce7983 @floere + qualifiers options -> qualifiers, qualifier, default:name
authored
131 end
Something went wrong with that request. Please try again.