Sha256: f9a53bfc4e26f81dd56e021c2703dfabb26d49c5dc63c811d8da783203ed9218

Contents?: true

Size: 1.52 KB

Versions: 17

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'

describe Picky::Sources::Mongo do

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

    context 'non-default' do
      let(:source) { described_class.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) { described_class.new(:a, :b, :url => 'someurl', :db => 'somedb') }
     it 'is correct' do
       source.to_s.should == 'Picky::Sources::Mongo'
     end
   end

   context "without database" do
     it "should fail correctly" do
       lambda { @source = described_class.new(:a, :b, :url => 'someurl') }.should raise_error(described_class::NoDBGiven)
     end
   end

   context "with database" do
     before(:each) do
       @source = described_class.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

17 entries across 17 versions & 1 rubygems

Version Path
picky-4.0.0pre1 spec/lib/sources/mongo_spec.rb
picky-3.6.16 spec/lib/sources/mongo_spec.rb
picky-3.6.15 spec/lib/sources/mongo_spec.rb
picky-3.6.14 spec/lib/sources/mongo_spec.rb
picky-3.6.13 spec/lib/sources/mongo_spec.rb
picky-3.6.12 spec/lib/sources/mongo_spec.rb
picky-3.6.11 spec/lib/sources/mongo_spec.rb
picky-3.6.10 spec/lib/sources/mongo_spec.rb
picky-3.6.9 spec/lib/sources/mongo_spec.rb
picky-3.6.8 spec/lib/sources/mongo_spec.rb
picky-3.6.7 spec/lib/sources/mongo_spec.rb
picky-3.6.6 spec/lib/sources/mongo_spec.rb
picky-3.6.4 spec/lib/sources/mongo_spec.rb
picky-3.6.3 spec/lib/sources/mongo_spec.rb
picky-3.6.2 spec/lib/sources/mongo_spec.rb
picky-3.6.1 spec/lib/sources/mongo_spec.rb
picky-3.6.0 spec/lib/sources/mongo_spec.rb