Hi, Would the BDD experts recommend I either (a) use fixtures for data or (b) stub out existing class methods for such a scenario?
Scenario = Working on a "populate for future transactions" method & testing this. It generates "transactions" table rows as part of the test. To do this it (a) requires BankAccount table row entries to be in place to ensure foreign key constraints allow new "transaction" to be added, i.e. with a bank_account_id which exists, and (b) ability to call the BankAccount class method "balance?(date)". Discussion = I've set things up with dynamic fixture type data using Ruby code (in the before(:each) do), however I was wondering whether in fact I should not be having to create such data (i.e. bank_account rows, when the real code under test is generating new "transaction" rows) but rather be "stubbing" out the existing methods on the BankAccount model (e.g. BankAccount.any_instance.stubs(:balance?).returns(<as required>)). Do people normal use the "any_instance.stubs" approach to stub out existing classes already developed, as a means to minimize associated test data that may have to be put in place to allow the test to work? Any other comments/suggestions re best practice here? Tks _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users