Sha256: 46faa621a6c28cc338b36991724262cfcf0078b0e7bc633919566a62e430abb5

Contents?: true

Size: 1.93 KB

Versions: 21

Compression:

Stored size: 1.93 KB

Contents

# encoding: utf-8
#
require 'spec_helper'

describe IndexAPI do
  
  context 'initializer' do
    it 'works' do
      lambda { IndexAPI.new :some_index_name, :some_source }.should_not raise_error
    end
    it 'registers with the indexes' do
      @api = IndexAPI.allocate
      
      Indexes.should_receive(:register).once.with @api
      
      @api.send :initialize, :some_index_name, :some_source
    end
  end
  
  context 'unit' do
    before(:each) do
      @api = IndexAPI.new :some_index_name, :some_source
    end

    describe 'define_category' do
      context 'with block' do
        it 'returns itself' do
          @api.define_category(:some_name){ |indexing, indexed| }.should == @api
        end
        it 'takes a string' do
          lambda { @api.define_category('some_name'){ |indexing, indexed| } }.should_not raise_error
        end
        it 'yields both the indexing category and the indexed category' do
          @api.define_category(:some_name) do |indexing, indexed|
            indexing.should be_kind_of(Indexing::Category)
            indexed.should be_kind_of(Indexed::Category)
          end
        end
        it 'yields the indexing category which has the given name' do
          @api.define_category(:some_name) do |indexing, indexed|
            indexing.name.should == :some_name
          end
        end
        it 'yields the indexed category which has the given name' do
          @api.define_category(:some_name) do |indexing, indexed|
            indexed.name.should == :some_name
          end
        end
      end
      context 'without block' do
        it 'works' do
          lambda { @api.define_category(:some_name) }.should_not raise_error
        end
        it 'takes a string' do
          lambda { @api.define_category('some_name').should == @api }.should_not raise_error
        end
        it 'returns itself' do
          @api.define_category(:some_name).should == @api
        end
      end
    end
  end
  
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
picky-1.4.1 spec/lib/index_api_spec.rb
picky-1.4.0 spec/lib/index_api_spec.rb
picky-1.3.4 spec/lib/index_api_spec.rb
picky-1.3.3 spec/lib/index_api_spec.rb
picky-1.3.2 spec/lib/index_api_spec.rb
picky-1.3.1 spec/lib/index_api_spec.rb
picky-1.3.0 spec/lib/index_api_spec.rb
picky-1.2.4 spec/lib/index_api_spec.rb
picky-1.2.3 spec/lib/index_api_spec.rb
picky-1.2.2 spec/lib/index_api_spec.rb
picky-1.2.1 spec/lib/index_api_spec.rb
picky-1.2.0 spec/lib/index_api_spec.rb
picky-1.1.7 spec/lib/index_api_spec.rb
picky-1.1.6 spec/lib/index_api_spec.rb
picky-1.1.5 spec/lib/index_api_spec.rb
picky-1.1.4 spec/lib/index_api_spec.rb
picky-1.1.3 spec/lib/index_api_spec.rb
picky-1.1.2 spec/lib/index_api_spec.rb
picky-1.1.1 spec/lib/index_api_spec.rb
picky-1.1.0 spec/lib/index_api_spec.rb