lib/spec/rails/mocks.rb in dchelimsky-rspec-rails-1.1.11.4 vs lib/spec/rails/mocks.rb in dchelimsky-rspec-rails-1.1.11.5

- old
+ new

@@ -102,24 +102,27 @@ stubs.each do |k,v| if model.has_attribute?(k) model[k] = stubs.delete(k) end end - add_stubs(model, stubs) + model.stub!(stubs) yield model if block_given? end end - #-- - # TODO - Shouldn't this just be an extension of stub! ?? - # - object.stub!(:method => return_value, :method2 => return_value2, :etc => etc) - #++ + # DEPRECATED - use object.stub!(:method => value, :method2 => value) + # # Stubs methods on +object+ (if +object+ is a symbol or string a new mock # with that name will be created). +stubs+ is a Hash of +method=>value+ def add_stubs(object, stubs = {}) #:nodoc: - m = [String, Symbol].index(object.class) ? mock(object.to_s) : object - stubs.each {|k,v| m.stub!(k).and_return(v)} - m + Kernel.warn <<-WARNING +DEPRECATION NOTICE: add_stubs is deprecated and will be removed +from a future version of rspec-rails. Use this instead: + + object.stub!(:method => value, :method2 => value) + +WARNING + object.stub!(stubs) end private @@model_id = 1000 def next_id