Questions about testing a module method that randomly creates stuff from list

All,

I have a method in a shared Module that shuffles data and then output
other
data. The method is somewhat large (maybe 50 lines) and sometimes
calls other
sub methods to help to complete the output which must meet a specific
criteria
or it re-shuffles.

My questions are:

  1. How do I capture that a sub method is called?
    Module.should_recieve(:sub_method) ???
  2. How do I capture the rand number that caused a condition (like the
    :sub_method being called, an Error raised, etc.). I know srand will
    give me the
    seed that caused it. But, how do I capture it on the failure? For
    example:
    true.should_not be_true || File.open(“capture_rand.out”,”a”) { |f|
    f.puts
    “#{srand}”}
    Can you do an || (or) statement like that and have it capture the seed
    and fail
    the example? Any ideas? Any other ways of capturing data like that?

After I capture the seeds, I’m thinking I could than use those seeds
to fine
tune specific tests.

Thanks,

GregD