Sha256: c6b911b22a8e0717d410fb0bbafb76a57c9727b450eb3f8a7b8541ab7e660736

Contents?: true

Size: 1.04 KB

Versions: 6

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

describe Sources::Couch do
  
  context "without database" do
    it "should fail correctly" do
      lambda { @source = Sources::Couch.new(:a, :b, :c) }.should raise_error(Sources::NoCouchDBGiven)
    end
  end
  
  context "with database" do
    before(:each) do
      @source = Sources::Couch.new :a, :b, :c, url: 'http://localhost:5984/picky'
      RestClient::Request.should_receive(:execute).any_number_of_times.and_return %{{"rows":[{"doc":{"_id":"7f","a":"a data","b":"b data","c":"c data"}}]}}
    end
    
    describe "harvest" do
      it "yields the right data" do
        field = stub :b, :from => :b
        @source.harvest :anything, field do |id, token|
          id.should    eql(127) 
          token.should eql('b data')
        end.should have(1).item
      end
    end
    
    describe "get_data" do
      it "yields each line" do
        @source.get_data do |data|
          data.should == { "_id" => "7f", "a" => "a data", "b" => "b data", "c" => "c data" }
        end.should have(1).item
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
picky-1.2.0 spec/lib/sources/couch_spec.rb
picky-1.1.7 spec/lib/sources/couch_spec.rb
picky-1.1.6 spec/lib/sources/couch_spec.rb
picky-1.1.5 spec/lib/sources/couch_spec.rb
picky-1.1.4 spec/lib/sources/couch_spec.rb
picky-1.1.3 spec/lib/sources/couch_spec.rb