Artūras Šlajus
2008-Feb-19 21:41 UTC
[rspec-users] Mocking kills usefullness of controller tests?
Hello, Let''s say we mock our User objects in controllers. Then we change attr_accessible in user.rb. Model tests break, controller do not. You fix the model ones and go on thinking everything is ok when it''s not (the controllers are broken). Even with technique in http://www.ruby-forum.com/topic/128149 you would only be testing if attr_accessible gets called. It wouldn''t show you places in your controllers where you need to change that mass assignment to attribute assignment. Any ideas how to prevent it? -- Posted via http://www.ruby-forum.com/.
Brian Takita
2008-Feb-19 21:55 UTC
[rspec-users] Mocking kills usefullness of controller tests?
On Feb 19, 2008 1:41 PM, Art?ras ?lajus <lists at ruby-forum.com> wrote:> Hello, > > Let''s say we mock our User objects in controllers. Then we change > attr_accessible in user.rb. Model tests break, controller do not. > > You fix the model ones and go on thinking everything is ok when it''s not > (the controllers are broken). > > Even with technique in http://www.ruby-forum.com/topic/128149 you would > only be testing if attr_accessible gets called. It wouldn''t show you > places in your controllers where you need to change that mass assignment > to attribute assignment. > > Any ideas how to prevent it?This is a common tradeoff when using mocks. You lose the integration aspects and arguably incur more maintenance overhead but gain speed and isolation. It looks like you want to have integration coverage over that code. You can either use controller specs without mocks, rails integration specs, and/or selenium (or watir) test that covers that piece of code.> -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >