Sha256: ef4f1fb22649053f165f00b8f20771d305c0b7d462fdb26005cd8bc2ca2f5a7e

Contents?: true

Size: 1.51 KB

Versions: 8

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

describe Sources::Mongo do
  
  describe 'key_format' do
    context 'default' do
      let(:source) { Sources::Mongo.new(:a, :b, :url => 'someurl', :db => 'somedb') }
      it 'is correct' do
        source.key_format.should == :to_sym
      end
    end

    context 'non-default' do
      let(:source) { Sources::Mongo.new(:a, :b, :url => 'bla', :db => 'somedb', :key_format => 'some_key_method') }
      it 'is correct' do
        source.key_format.should == :some_key_method
      end
    end
  end
  
  describe 'to_s' do
     let(:source) { Sources::Mongo.new(:a, :b, :url => 'someurl', :db => 'somedb') }
     it 'is correct' do
       source.to_s.should == 'Sources::Mongo'
     end
   end
   
   context "without database" do
     it "should fail correctly" do
       lambda { @source = Sources::Mongo.new(:a, :b, :url => 'someurl') }.should raise_error(Sources::NoMongoDBGiven)
     end
   end

   context "with database" do
     before(:each) do
       @source = Sources::Mongo.new :a, :b, :url => 'someurl', :db => 'somedb'
       RestClient::Request.should_receive(:execute).any_number_of_times.and_return %{{"rows":[{"_id":"7f","a":"a data","b":"b data","c":"c data"}]}}
     end

     describe "harvest" do
       it "yields the right data" do
         category = stub :b, :from => :b, :index_name => :some_index_name
         @source.harvest category do |id, token|
           id.should    eql('7f') 
           token.should eql('b data')
         end.should have(1).item
       end
     end
   end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
picky-2.7.0 spec/lib/sources/mongo_spec.rb
picky-2.6.0 spec/lib/sources/mongo_spec.rb
picky-2.5.2 spec/lib/sources/mongo_spec.rb
picky-2.5.1 spec/lib/sources/mongo_spec.rb
picky-2.5.0 spec/lib/sources/mongo_spec.rb
picky-2.4.3 spec/lib/sources/mongo_spec.rb
picky-2.4.2 spec/lib/sources/mongo_spec.rb
picky-2.4.1 spec/lib/sources/mongo_spec.rb