if you want to prevent other runs of SCR.Execute then defined, then you should use exceptions or even better, create mock object that accept only you calls like I did in this code - https://github.com/yast/yast-cio/blob/master/test/channels_dialog_spec.rb#L45 . In general you replace SCR with your special object that accept only your defined calls and provide really nice error message if something strange is passed.