lib/spec/rr/mocks.rb
def stub_model(model_class, stubs={})
    stubs = {:id => next_id}.merge(stubs)
    returning model_class.new do |model|
      model.id = stubs.delete(:id)
      model.extend Spec::Rails::Mocks::ModelStubber
      stubs.each do |k,v|
        if model.has_attribute?(k)
          model[k] = stubs.delete(k)
        end
      end
      stubs.each do |k,v|
        stub(model).__send__(k) { v }
      end
      yield model if block_given?
    end
  end
# Creates a mock object instance for a +model_class+ with common
# methods stubbed out. Additional methods may be easily stubbed (via
# add_stubs) if +stubs+ is passed.
Creates a mock object instance for a +model_class+ with common
methods stubbed out. Additional methods may be easily stubbed (via
add_stubs) if +stubs+ is passed.
Creates a mock object instance for a + model_class + with common methods stubbed out . Additional methods may be easily stubbed ( via add_stubs ) if + stubs + is passed .
def stub_model(model_class, stubs={})
    stubs = {:id => next_id}.merge(stubs)
    returning model_class.new do |model|
      model.id = stubs.delete(:id)
      model.extend Spec::Rails::Mocks::ModelStubber
      stubs.each do |k,v|
        if model.has_attribute?(k)
          model[k] = stubs.delete(k)
        end
      end
      stubs.each do |k,v|
        stub(model).__send__(k) { v }
      end
      yield model if block_given?
    end
  end
def stub_model ( model_class , stubs = { } ) stubs = { :id => next_id } . merge ( stubs ) returning model_class . new do | model | model . id = stubs . delete ( :id ) model . extend Spec :: Rails :: Mocks :: ModelStubber stubs . each do | k , v | if model . has_attribute? ( k ) model [ k ] = stubs . delete ( k ) end end stubs . each do | k , v | stub ( model ) . __send__ ( k ) { v } end yield model if block_given? end end
Creates a mock object instance for a +model_class+ with common
methods stubbed out.
Creates a mock object instance for a + model_class + with common methods stubbed out .
model_class
stubs