Hey Rob,
Sounds like an interesting, useful project!
Dynamically generating examples works fine as long as they are all generated during the “load spec files” phase, before the first spec runs. Defining additional examples while the examples run isn’t going to work very well. A lot of RSpec’s features (e.g. randomization and metadata filtering) need to be able to get the complete list of examples before the first one runs so that these features can do their thing. In addition, other features in 3.3 (bisect and —only-failures) rely the example IDs being stable — that is, spec/foo_spec.rb[1:10] needs to consistently reference the same example (in this case, the 10th example in the 1st example group in spec/foo_spec.rb) on each run of the suite to work properly. If you are generating additional examples as the specs run the ids may not be consistent and you’re going to break some of RSpec’s features.
My suggestion is to change how you model the problem. From what you described, you are modeling each assertion as a separate RSpec example. This is natural, given that each assertion represents an example of the property being verified and RSpec has something called an example as well. However, I think you’ll have better success if you model each property as a separate RSpec example, and then have that RSpec example delegate to a bit of code you’ve written that dynamically generates and runs as many assertions as necessary against as many input examples as necessary — and then reports the results back to RSpec in the form of no exception (if the property passed all checks) or an exception with a good, detailed message if the property failed a check.
Does that make sense?
BTW, I’m leaving for a long vacation tonight and will have sporadic access to email so I may not see or respond to replies for quite some time. I’m sure others can help out, though :).
HTH,
Myron
--
You received this message because you are subscribed to the Google Groups "rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+un...@googlegroups.com.
To post to this group, send email to rs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/CALx9tg3ixVUQOrnu6yCdpr1TSWQhNRW_ohOJn8p0X0LCPNCE0w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/CADUxQmuQK9riLFoZ50pEJpERaY97FU7Yuza9mkmzbNw%2BR9uMSg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/CAK-y3Cthyi-CYQsvL3zk8_ZaxuA%3DcUS7%3DBoMdb50Y5KELrDGfA%40mail.gmail.com.