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


I have a method in a shared Module that shuffles data and then output
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
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
    true.should_not be_true ||“capture_rand.out”,”a”) { |f|
    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.



This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs