Sha256: f2b66f5fe1521748a5bedc93e1d6691dd8a9c2e1460db961802a70763dfefacf

Contents?: true

Size: 924 Bytes

Versions: 5

Compression:

Stored size: 924 Bytes

Contents

require 'spec_helper'

describe CouchPotato::View::ViewQuery, 'query_view' do
  it "should not pass a key if conditions are empty" do
    db = mock 'db', :get => nil, :save_doc => nil
    db.should_receive(:view).with(anything, {})
    CouchPotato::View::ViewQuery.new(db, '', '', '', '').query_view!
  end
  
  it "should not update a view when the functions haven't changed" do
    db = mock 'db', :get => {'views' => {'view' => {'map' => 'map', 'reduce' => 'reduce'}}}, :view => nil
    db.should_not_receive(:save_doc)
    CouchPotato::View::ViewQuery.new(db, 'design', 'view', 'map', 'reduce').query_view!
  end
  
  it "should update a view when the functions have changed" do
    db = mock 'db', :get => {'views' => {'view2' => {'map' => 'map', 'reduce' => 'reduce'}}}, :view => nil
    db.should_receive(:save_doc)
    CouchPotato::View::ViewQuery.new(db, 'design', 'view2', 'mapnew', 'reduce').query_view!
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
couch_potato-0.2.32 spec/unit/view_query_spec.rb
couch_potato-0.2.31 spec/unit/view_query_spec.rb
couch_potato-0.2.30 spec/unit/view_query_spec.rb
couch_potato-0.2.29 spec/unit/view_query_spec.rb
couch_potato-0.2.28 spec/unit/view_query_spec.rb