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
I finally managed to make a test that works for me:
mutation = FactoryGirl.build(:mutation)
Mutation.stub(:new).and_return(mutation)
mutation.should_receive(:save).at_least(:once)
The stub method returns one single instance that receives the save method multiple times. Because it is a single instance i can drop the any_instance method and use the at_least method normally.