spec/lib/internals/index/redis_spec.rb in picky-2.1.2 vs spec/lib/internals/index/redis_spec.rb in picky-2.2.0
- old
+ new
@@ -1,74 +1,147 @@
require 'spec_helper'
describe Internals::Index::Redis do
-
- let(:config) do
- index = stub :index, :name => :some_index
- category = stub :category, :name => :some_category
- Configuration::Index.new index, category
- end
- let(:redis) { described_class.new :some_name, config }
-
- describe 'setting' do
- it 'delegates to the configuration' do
- configuration = stub :configuration
- redis.stub! :configuration => configuration
- configuration.should_receive(:member).once.with :some_sym
-
- redis.setting :some_sym
+ context 'indexing' do
+ let(:category) do
+ index = stub :index, :name => :some_index
+ category = Internals::Indexing::Category.new :some_category, index
end
- it 'returns the value' do
- configuration = stub :configuration
- redis.stub! :configuration => configuration
+ let(:redis) { described_class.new :some_name, category }
- configuration.should_receive(:member).any_number_of_times.and_return "some config"
+ describe 'setting' do
+ it 'delegates to the configuration' do
+ configuration = stub :configuration
+ redis.stub! :configuration => configuration
- redis.setting(:any).should == "some config"
- end
- end
- describe 'weight' do
- it 'delegates to the weights' do
- weights = stub :weights
- redis.stub! :weights => weights
+ configuration.should_receive(:member).once.with :some_sym
- weights.should_receive(:member).once.with :some_sym
+ redis.setting :some_sym
+ end
+ it 'returns the value' do
+ configuration = stub :configuration
+ redis.stub! :configuration => configuration
- redis.weight :some_sym
+ configuration.should_receive(:member).any_number_of_times.and_return "some config"
+
+ redis.setting(:any).should == "some config"
+ end
end
- it 'returns a floated value' do
- weights = stub :weights
- redis.stub! :weights => weights
+ describe 'weight' do
+ it 'delegates to the weights' do
+ weights = stub :weights
+ redis.stub! :weights => weights
- weights.should_receive(:member).any_number_of_times.and_return "1.0"
+ weights.should_receive(:member).once.with :some_sym
- redis.weight(:any).should == 1.0
+ redis.weight :some_sym
+ end
+ it 'returns a floated value' do
+ weights = stub :weights
+ redis.stub! :weights => weights
+
+ weights.should_receive(:member).any_number_of_times.and_return "1.0"
+
+ redis.weight(:any).should == 1.0
+ end
+ it 'returns a floated value' do
+ weights = stub :weights
+ redis.stub! :weights => weights
+
+ weights.should_receive(:member).any_number_of_times.and_return 1
+
+ redis.weight(:any).should == 1.0
+ end
end
- it 'returns a floated value' do
- weights = stub :weights
- redis.stub! :weights => weights
+ describe 'ids' do
+ it 'delegates to the index' do
+ index = stub :index
+ redis.stub! :index => index
- weights.should_receive(:member).any_number_of_times.and_return 1
+ index.should_receive(:collection).once.with :some_sym
- redis.weight(:any).should == 1.0
+ redis.ids :some_sym
+ end
+ it 'returns the value' do
+ index = stub :index
+ redis.stub! :index => index
+
+ index.should_receive(:collection).any_number_of_times.and_return [1,2,3]
+
+ redis.ids(:any).should == [1,2,3]
+ end
end
end
- describe 'ids' do
- it 'delegates to the index' do
- index = stub :index
- redis.stub! :index => index
+
+ context 'indexed' do
+ let(:category) do
+ index = stub :index, :name => :some_index
+ category = Internals::Indexed::Category.new :some_category, index
+ end
+ let(:redis) { described_class.new :some_name, category }
- index.should_receive(:collection).once.with :some_sym
+ describe 'setting' do
+ it 'delegates to the configuration' do
+ configuration = stub :configuration
+ redis.stub! :configuration => configuration
- redis.ids :some_sym
+ configuration.should_receive(:member).once.with :some_sym
+
+ redis.setting :some_sym
+ end
+ it 'returns the value' do
+ configuration = stub :configuration
+ redis.stub! :configuration => configuration
+
+ configuration.should_receive(:member).any_number_of_times.and_return "some config"
+
+ redis.setting(:any).should == "some config"
+ end
end
- it 'returns the value' do
- index = stub :index
- redis.stub! :index => index
+ describe 'weight' do
+ it 'delegates to the weights' do
+ weights = stub :weights
+ redis.stub! :weights => weights
- index.should_receive(:collection).any_number_of_times.and_return [1,2,3]
+ weights.should_receive(:member).once.with :some_sym
- redis.ids(:any).should == [1,2,3]
+ redis.weight :some_sym
+ end
+ it 'returns a floated value' do
+ weights = stub :weights
+ redis.stub! :weights => weights
+
+ weights.should_receive(:member).any_number_of_times.and_return "1.0"
+
+ redis.weight(:any).should == 1.0
+ end
+ it 'returns a floated value' do
+ weights = stub :weights
+ redis.stub! :weights => weights
+
+ weights.should_receive(:member).any_number_of_times.and_return 1
+
+ redis.weight(:any).should == 1.0
+ end
end
+ describe 'ids' do
+ it 'delegates to the index' do
+ index = stub :index
+ redis.stub! :index => index
+
+ index.should_receive(:collection).once.with :some_sym
+
+ redis.ids :some_sym
+ end
+ it 'returns the value' do
+ index = stub :index
+ redis.stub! :index => index
+
+ index.should_receive(:collection).any_number_of_times.and_return [1,2,3]
+
+ redis.ids(:any).should == [1,2,3]
+ end
+ end
end
+
end
\ No newline at end of file