Sha256: 17ee9d3b3c4a1122c9e82e6e7ad3849090bff5c09a6eed2f6d055fae10504e7e

Contents?: true

Size: 865 Bytes

Versions: 11

Compression:

Stored size: 865 Bytes

Contents

require 'spec_helper'
require 'couch_potato/rspec'

class WithStubbedView
  include CouchPotato::Persistence
  
  view :stubbed_view, :key => :x
end

describe "stubbing the db" do
  it "should replace CouchPotato.database with a stub" do
    stub_db
    CouchPotato.database.should be_a(Spec::Mocks::Mock)
  end
  
  it "should return the stub" do
    db = stub_db
    CouchPotato.database.should == db
  end
end

describe "stubbing a view" do
  before(:each) do
    @db = stub_db
    @db.stub_view(WithStubbedView, :stubbed_view).with('123').and_return([:result])
  end
  
  it "should stub the view to return a stub" do
    WithStubbedView.stubbed_view('123').should be_a(Spec::Mocks::Mock)
  end
  
  it "should stub the database to return fake results when called with the stub" do
    @db.view(WithStubbedView.stubbed_view('123')).should == [:result]
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
davber_couch_potato-0.4.0 spec/unit/rspec_stub_db_spec.rb
couch_potato-0.4.0 spec/unit/rspec_stub_db_spec.rb
couch_potato-0.3.2 spec/unit/rspec_stub_db_spec.rb
couch_potato-0.3.1 spec/unit/rspec_stub_db_spec.rb
davber_couch_potato-0.3.0 spec/unit/rspec_stub_db_spec.rb
couch_potato-0.3.0 spec/unit/rspec_stub_db_spec.rb
couch_potato-0.2.32 spec/unit/rspec_stub_db_spec.rb
couch_potato-0.2.31 spec/unit/rspec_stub_db_spec.rb
couch_potato-0.2.30 spec/unit/rspec_stub_db_spec.rb
couch_potato-0.2.29 spec/unit/rspec_stub_db_spec.rb
couch_potato-0.2.28 spec/unit/rspec_stub_db_spec.rb