Please correct me if this is fixed in Rspec 2, but in Rspec 1 I have hit upon the following problem (at least thrice, this time it costing me several hours), code is the best example:
I have a practice examination system where each record is one of several "subtests" (think tagging rather than subclassing) which is part of a constant string array. I want to test each's behaviour indepently in my specs (since an earlier implementation used STI rather than tagging, and I want to test each kind of test follows the spec) My specs use this approach in parts: describe "#add_question_set_of_type" do MyModule::SUBTESTS.each do |subtest| describe %Q("#{subtest}") do … specs using subtest end end where SUBTESTS is a constant array of strings. the problem is doing this breaks any blocks that look like let(:subtest) {MyModule.subtest_to_sym(subtest)} or before(:each) do @subtest = MyModule.subtest_to_sym(subtest) end Instead I have to avoid the @ or let examples, and use the more explicit (verbose): MyModule.subtest_to_sym(subtest) using the let or before @ approaches both fail. Using puts within the code (for debugging purposes) I found that the specs were only being exposed to the final value of the array, while I expected (and have seen, or at least assumed from past passes) that all 4 (or so) of the strings were being used to create unique methods on the example group (one per iteration). Is this something that should be: a. avoided, because it's crazy, and written differently b, documented c. investigated further I can provide a more complete example if helpful? Thanks, Nick _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users