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.
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
Thanks for replay, but what is difference from such spec to rails unit test?