On Sun, Jan 17, 2010 at 8:17 PM, Nin <npdepolo...@gmail.com> wrote: > Hi! I'm new to rspec and was wondering how named_scopes are usually > tested? Is it enough to test that it's defined? or do you need to test > the behavior as well? I've been reading around and this seems to be > the tester's choice, i just want to get people's opinion on this :D >
_Specify_ the behaviour, don't _test_ the implementation. The fact that a method is defined with a named_scope declaration is irrelevant to the behaviour. One reason for this is keeping things decoupled. Consider the fact that named_scope just changed to scope today [1]. If your specs specify a call to named_scope, they'll have to change, whereas if they they only specify the name you define then you'll only need to update the implementation when you upgrade. [1] http://github.com/rails/rails/commit/d60bb0a9e4be2ac0a9de9a69041a4ddc2e0cc914 That all make sense?
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users