Hi all. Could anybody help me with Rspec? I think that Rspec is used such a way: 1.I decide MyModel must have method my_method which return array of 2 model objects. 2.I write spec where I use stub instead of my_method 3.I create my_method in MyModel and write code of it. 4.I comment stub definition in my spec and use spec as test Is it right? Thanks. Bye. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
not really. Stubs are used to isolate code you want to test, apart from other code, so you stub out the calls that you''re not testing here. So for model tests 1. decide... 2. write spec to test the model method, test fails 3. write model method to implement the spec 4. run spec again, it succeeds when you are ready to spec a method that calls the model one you just wrote, than you could stub the model method so the new code doesnt depend on it. linoj On May 31, 8:36 am, "shator...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <shator...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all. > Could anybody help me with Rspec? > I think that Rspec is used such a way: > 1.I decide MyModel must have method my_method which return array of 2 > model objects. > 2.I write spec where I use stub instead of my_method > 3.I create my_method in MyModel and write code of it. > 4.I comment stub definition in my spec and use spec as test > Is it right? > Thanks. > Bye.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
shatorkin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jun-01 06:51 UTC
Re: Rspec ideology
Thanks for replay, but what is difference from such spec to rails unit test? On 31 май, 21:24, linoj <lino...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> not really. > Stubs are used to isolate code you want to test, apart from other > code, so you stub out the calls that you''re not testing here. > > So for model tests > 1. decide... > 2. write spec to test the model method, test fails > 3. write model method to implement the spec > 4. run spec again, it succeeds > > when you are ready to spec a method that calls the model one you just > wrote, than you could stub the model method so the new code doesnt > depend on it. > > linoj > > On May 31, 8:36 am, "shator...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <shator...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi all. > > Could anybody help me with Rspec? > > I think that Rspec is used such a way: > > 1.I decide MyModel must have method my_method which return array of 2 > > model objects. > > 2.I write spec where I use stub instead of my_method > > 3.I create my_method in MyModel and write code of it. > > 4.I comment stub definition in my spec and use spec as test > > Is it right? > > Thanks. > > Bye.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---