[rspec-users] Mock and Stub objects

Amit Kulkarni lists at ruby-forum.com
Thu Jun 11 05:39:28 EDT 2009


Matt Wynne wrote:
> On 11 Jun 2009, at 08:17, Amit Kulkarni wrote:
> 
>>>>
>> those objects.
>> it
>> be fine?
> 
> If you're writing the specs after you've written the code, you're
> losing a lot of the value of mock objects.

Actually i am writing specs before the code is written.I saw many 
examples especially in controllers they are using mocks.So i was bit 
confused regarding the same.

Also Imagine the same situation where code is written and we are writing 
specs for that then is it necessary to use mocks?If Yes why since code 
is already written?

> Mock objects were originally devised as a design tool for use when
> doing TDD. TDD stands for Test *Driven* Development, meaning that you
> write the test before you have written any of the code. When you're
> doing this, you want to be able to build the system piece by piece,
> class by class, so you write tests for a single object at a time, and
> use mock objects to assemble quick, lightweight sketches of the
> surrounding objects that you imagine it will interact with when the
> system is finished.
> 
>> Also since i am using the beta version Mocking Objects part is not
>> there.And it is does not give clearcut idea from the topic Mock  
>> Objects.
>> Also it will be very helpful if you can provide me a link or anything
>> which can give me details of Mocks and Stubs.How to use it?When to use
>> it..e.t.c
> 
> This is a big topic which is not going to be easy to explain over
> email. Here is some more stuff for you to read.
> 
> http://www.patmaddox.com/blog/you-probably-dont-get-mocks
> http://www.mockobjects.com/book/
> http://www.jmock.org/oopsla2004.pdf
> http://www.martinfowler.com/articles/mocksArentStubs.html

Thanks a lot Matt for the above links.
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list