Sha256: 7c6a9ab453761d9b9561da46e08a346df75ddbaaf9c274d276cfd899abfee56f

Contents?: true

Size: 1 KB

Versions: 25

Compression:

Stored size: 1 KB

Contents

require 'spec_helper'

describe CouchPotato::View::CustomViewSpec, '#process_results' do
  it 'returns the documents' do
    spec = CouchPotato::View::CustomViewSpec.new(Child, 'all', {}, {})
    processed_results = spec.process_results('rows' => [{'doc' => {JSON.create_id => 'Child'}}])

    expect(processed_results.map{|row| row.class}).to eql([Child])
  end

  it 'returns values where there are no documents' do
    spec = CouchPotato::View::CustomViewSpec.new(Child, 'all', {}, {:include_docs => false})
    processed_results = spec.process_results('rows' => [{'value' => {JSON.create_id => 'Child'}}])

    expect(processed_results.map{|row| row.class}).to eql([Child])
  end

  it 'filters out rows without documents when include_docs=true (i.e. doc has been deleted)' do
    spec = CouchPotato::View::CustomViewSpec.new(Child, 'all', {}, {:include_docs => true})
    processed_results = spec.process_results('rows' => [{'value' => {JSON.create_id => 'Child'}}])

    expect(processed_results).to be_empty
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
couch_potato-1.1.2 spec/unit/custom_view_spec_spec.rb
couch_potato-1.1.1 spec/unit/custom_view_spec_spec.rb
couch_potato-1.1.0 spec/unit/custom_view_spec_spec.rb
couch_potato-1.0.1 spec/unit/custom_view_spec_spec.rb
couch_potato-1.0.0 spec/unit/custom_view_spec_spec.rb