I\'ve got an import controller in rails that imports several csv files with multiple records into my database. I would like to test in RSpec if the records are actually save
Stub like this
User.stub(:save) # Could be any class method in any class
User.any_instance.stub(:save) { |*args| User.save(*args) }
Then expect like this:
# User.any_instance.should_receive(:save).at_least(:once)
User.should_receive(:save).at_least(:once)
This is a simplification of this gist, to use any_instance, since you don't need to proxy to the original method. Refer to that gist for other uses.