Richard Schneeman wrote: > I just started using rspec and mocha to test all of my controllers. > Before I was using factory girl to test do my testing, but all those > database hits really take a long time.
Are you sure that's where you're losing time? (For the record, I'm using and loving Machinist.) > However i'm finding i'm spending > way more time writing stubs and mocks to satisfy my controllers than I > am actually writing tests. Then that's a sign that something is wrong...perhaps those DB hits aren't so bad! :) > > This is a two part general question > 1) Am i doing something completely wrong in my controllers? I'm testing > with integrate_views and the number of times something.stubs(:each) > comes up way to often in my specs. Most of my controllers involve at > least 2 normally 3 models. > > 2) Is there a way to auto generate stubs and mocks like factory-girl, so > i don't have to worry about populating every last property of every last > mock_model'd ? I can just call Mock_Factory.create(:website) and set up > a list of defaults somewhere else? The answer to both of these questions is: go back to using factories. If you don't like Factory Girl, try Machinist. Also, you might want to think about writing fewer controller specs and using Cucumber more... > > > I feel like my stubs and mocks are supposed to help me, not confuse me: > > http://pastie.org/641647 Yeah, that lookls like the kind of stuff I used to write before Machinist... > > > Your thoughts? Best, -- Marnen Laibow-Koser http://www.marnen.org [email protected] -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

