# Rspec ideology

**URL:** <https://www.ruby-forum.com/t/rspec-ideology/105590>\
**Category:** Rails\
**Created:** [May 31, 2007, 2:37pm UTC](https://www.ruby-forum.com/t/rspec-ideology/105590 "2007-05-31T14:37:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 31, 2007, 2:37pm UTC](https://www.ruby-forum.com/t/rspec-ideology/105590/1 "2007-05-31T14:37:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 31, 2007, 8:25pm UTC](https://www.ruby-forum.com/t/rspec-ideology/105590/2 "2007-05-31T20:25:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 1, 2007, 8:53am UTC](https://www.ruby-forum.com/t/rspec-ideology/105590/3 "2007-06-01T08:53:00Z")

</div>

Thanks for replay,  
but what is difference from such spec to rails unit test?
