Sha256: 9c26d7c25dde3164ddb80b46993825fd6bb72b64e4489b0834592442c0791b33

Contents?: true

Size: 867 Bytes

Versions: 12

Compression:

Stored size: 867 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(RSpec::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(RSpec::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

12 entries across 12 versions & 2 rubygems

Version Path
couch_potato-rails2-0.5.10 spec/unit/rspec_stub_db_spec.rb
couch_potato-rails2-0.5.9 spec/unit/rspec_stub_db_spec.rb
couch_potato-rails2-0.5.8 spec/unit/rspec_stub_db_spec.rb
couch_potato-rails2-0.5.7 spec/unit/rspec_stub_db_spec.rb
couch_potato-rails2-0.5.6 spec/unit/rspec_stub_db_spec.rb
couch_potato-0.5.6 spec/unit/rspec_stub_db_spec.rb
couch_potato-0.5.5 spec/unit/rspec_stub_db_spec.rb
couch_potato-0.5.4 spec/unit/rspec_stub_db_spec.rb
couch_potato-0.5.3 spec/unit/rspec_stub_db_spec.rb
couch_potato-0.5.2 spec/unit/rspec_stub_db_spec.rb
couch_potato-0.5.1 spec/unit/rspec_stub_db_spec.rb
couch_potato-0.5.0 spec/unit/rspec_stub_db_spec.rb