Sha256: daf3edd26c0ab92308f7939cbe569c5d6efa2d006302515db7a4a57c14337a42

Contents?: true

Size: 953 Bytes

Versions: 3

Compression:

Stored size: 953 Bytes

Contents

require File.dirname(__FILE__) + '/../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

3 entries across 3 versions & 1 rubygems

Version Path
couch_potato-0.2.27 spec/unit/view_query_spec.rb
couch_potato-0.2.26 spec/unit/view_query_spec.rb
couch_potato-0.2.25 spec/unit/view_query_spec.rb