Suppose a "User" has many "widgets", and that we have a method in the User
class that does something like:

def update_widgets
  x = ... code to do some calculations ...
  if x > 5
    new_widget = widgets.new
    new_widget.save!
  else
    widgets.first.destroy
  end

  widgets.reload
end

How would one spec this without having to worry about the validations for
new_widget?  Is there any way in the spec to tell it to replace instances of
save! with instances of save(false) or something along those lines? Using
message expectations is difficult in this case because the new_widget
doesn't exist before the method is called, so there's not object that can
ahead of time expect to receive the save! method.

Thanks..
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to