From: Jeremy Bopp Date: 2010-12-02T05:34:57+09:00 Subject: Re: mocking in rspec On 12/1/2010 12:21 PM, Ruby Pasaulyje wrote: > I have a problem with mocking. I have class DistanceMatrix and I would > like to indicate which method form_matrix is called in if/else > statement. I need to use mocha and rspec. Any ideas? > > > class DistanceMatrix > > def initialize(*args) > if args[0].class == String > form_matrix(get_data_from_yaml(args[0], args[1])) > elsif args[0].class == Array || args[0] == nil > form_matrix(get_data_from_db(args[0])) > end > end > > def form_matrix() > ... > end > > end If you really need to tie your tests to such implementation details, perhaps you could also mock get_data_from_yaml and get_data_from_db and check to see which is called each time form_matrix is called. -Jeremy