Sha256: c4fa8a7a6d2b4bdfbc55ee1fcbdbb34e6aa4e6d5f459006246569f144c93b6cf
Contents?: true
Size: 955 Bytes
Versions: 12
Compression:
Stored size: 955 Bytes
Contents
module CouchPotato::RSpec module StubView class ViewStub def initialize(clazz, view, db) @clazz = clazz @view = view @db = db end def with(*args) @args = args self end def and_return(return_value) view_stub = RSpec::Mocks::Mock.new("#{@clazz}.#{@view}(#{@args.try(:join, ', ')}) view") _stub = @clazz.stub(@view) _stub.with(*@args) if @args _stub.and_return(view_stub) @db.stub(:view).with(view_stub).and_return(return_value) end end def stub_view(clazz, view) ViewStub.new clazz, view, self end end module StubDb def stub_db(options = {}) db = stub('db', options) db.extend CouchPotato::RSpec::StubView CouchPotato.stub(:database => db) db end end end module RSpec module Mocks module ExampleMethods include CouchPotato::RSpec::StubDb end end end
Version data entries
12 entries across 12 versions & 2 rubygems