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