spec/lib/indexes_spec.rb in picky-3.2.0 vs spec/lib/indexes_spec.rb in picky-3.3.0
- old
+ new
@@ -1,39 +1,50 @@
require 'spec_helper'
describe Picky::Indexes do
- before(:each) do
- @index = stub :some_index, :name => :some_index
- @indexes = described_class.instance
- end
+ let(:index) { stub :some_index, :name => :some_index }
- describe 'indexes' do
- it 'exists' do
- lambda { @indexes.indexes }.should_not raise_error
+ context 'with instance' do
+ let(:indexes) { Picky::Indexes.new }
+
+ describe 'indexes' do
+ it 'exists' do
+ lambda { indexes.indexes }.should_not raise_error
+ end
+ it 'is empty by default' do
+ indexes.indexes.should be_empty
+ end
end
- it 'is empty by default' do
- @indexes.indexes.should be_empty
- end
end
- describe 'clear_indexes' do
- it 'clears the indexes' do
- @indexes.register @index
+ context 'with singleton' do
+ let(:indexes) { Picky::Indexes.instance }
- @indexes.clear_indexes
+ describe 'indexes' do
+ it 'exists' do
+ lambda { indexes.indexes }.should_not raise_error
+ end
+ end
- @indexes.indexes.should == []
+ describe 'clear_indexes' do
+ it 'clears the indexes' do
+ indexes.register index
+
+ indexes.clear_indexes
+
+ indexes.indexes.should == []
+ end
end
- end
- describe 'register' do
- it 'adds the given index to the indexes' do
- @indexes.clear_indexes
-
- @indexes.register @index
+ describe 'register' do
+ it 'adds the given index to the indexes' do
+ indexes.clear_indexes
- @indexes.indexes.should == [@index]
+ indexes.register index
+
+ indexes.indexes.should == [index]
+ end
end
end
end
\ No newline at end of file