spec/lib/backend/files_spec.rb in picky-2.6.0 vs spec/lib/backend/files_spec.rb in picky-2.7.0
- old
+ new
@@ -8,11 +8,11 @@
@files = described_class.new :some_name, category
@prepared = @files.prepared
- @index = @files.index
+ @index = @files.inverted
@weights = @files.weights
@similarity = @files.similarity
@configuration = @files.configuration
end
@@ -23,15 +23,18 @@
@files.retrieve
end
end
describe "dump indexes" do
+ before(:each) do
+ @files.stub! :timed_exclaim
+ end
describe "dump_index" do
it "uses the right file" do
@index.should_receive(:dump).once.with :some_hash
- @files.dump_index :some_hash
+ @files.dump_inverted :some_hash
end
end
describe "dump_weights" do
it "uses the right file" do
@weights.should_receive(:dump).once.with :some_hash
@@ -61,13 +64,13 @@
end
describe "load_index" do
it "uses the right file" do
Yajl::Parser.stub! :parse
- File.should_receive(:open).once.with 'spec/test_directory/index/test/some_index/some_category_some_name_index.json', 'r'
+ File.should_receive(:open).once.with 'spec/test_directory/index/test/some_index/some_category_some_name_inverted.json', 'r'
- @files.load_index
+ @files.load_inverted
end
end
describe "load_weights" do
it "uses the right file" do
Yajl::Parser.stub! :parse
@@ -100,11 +103,11 @@
describe "dump indexes" do
describe "index_cache_ok?" do
it 'uses the right method' do
@index.should_receive(:cache_ok?).once.with
- @files.index_cache_ok?
+ @files.inverted_cache_ok?
end
end
describe "weights_cache_ok?" do
it 'uses the right method' do
@weights.should_receive(:cache_ok?).once.with
@@ -120,15 +123,15 @@
end
end
end
describe 'dump indexes' do
- describe 'index_cache_small?' do
+ describe 'inverted_cache_small?' do
it 'uses the right method' do
@index.should_receive(:cache_small?).once.with
- @files.index_cache_small?
+ @files.inverted_cache_small?
end
end
describe 'weights_cache_small?' do
it 'uses the right method' do
@weights.should_receive(:cache_small?).once.with
@@ -177,9 +180,20 @@
end
describe 'initialization' do
it 'should initialize the name correctly' do
@files.bundle_name.should == :some_name
+ end
+ end
+
+ describe 'to_s' do
+ it 'returns the right value' do
+ category = stub :category,
+ :identifier => "category_identifier",
+ :prepared_index_path => "prepared/index/path",
+ :index_path => 'index/path'
+
+ described_class.new("some_bundle", category).to_s.should == "Backend::Files(Backend::File::Text(prepared/index/path.txt), Backend::File::JSON(index/path.json), Backend::File::JSON(index/path.json), Backend::File::Marshal(index/path.dump), Backend::File::JSON(index/path.json))"
end
end
end
\ No newline at end of file