Forum: RSpec Good introduction to rspec

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Dfedc33617bd10e9d1b57c1d835f2164?d=identicon&s=25 Pablo L. de Miranda (Guest)
on 2009-03-31 19:40
(Received via mailing list)
Hi guys,
Someone know some good introduction to rspec, I`m wanting to use Rspec
with
my Rails projects, but I don't found a good introduction.

Att,

Pablo Lacerda de Miranda
pablolmiranda@gmail.com
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2009-03-31 19:59
Pablo L. de Miranda wrote:
> Hi guys,
> Someone know some good introduction to rspec, I`m wanting to use Rspec
> with
> my Rails projects, but I don't found a good introduction.
>

From my own experience:

Write specs for your models and their class / instance methods. If you
find yourself struggling to do that, it's probably that too much logic
is floating in your controllers, so move it to your model as much as you
can.

It took me roughly 5 tries to get a hang of RSpec. By tries I mean: I
start writing specs, then get pissed off and stop for a few
weeks/months, then get back to it again.

Don't bother specing your controllers and views. Just stick to the
models or you'll get pissed off.

To spec controllers and views use Cucumber and webrat, but don't dive
into it right now.

Oh and by the way, don't use fixtures, instead write your own Factory.

Be very patient, don't try to do too much at a time, and have fun :-)
Dfedc33617bd10e9d1b57c1d835f2164?d=identicon&s=25 Pablo L. de Miranda (Guest)
on 2009-04-01 00:41
(Received via mailing list)
Hi Fernando,
Are know, or have, some material ( tutorial, article, etc.. ) to
recommend
me?

Att,

Pablo Lacerda de Miranda
Graduando Sistemas de Informação
Universidade Estadual de Montes Claros
pablolmiranda@gmail.com
A76239db5edcb9923d04687bda88cf27?d=identicon&s=25 Sarah Gray (sarahg)
on 2009-04-01 01:06
(Received via mailing list)
There are some great peepcode screencasts, if you like that kind of
thing:

http://peepcode.com/products/rspec-basics
http://peepcode.com/products/rspec-mocks-and-models
http://peepcode.com/products/rspec-controllers-and-tools

Also the book is coming out it's in beta now,
http://www.pragprog.com/titles/achbd/the-rspec-book

hth.

2009/3/31 Pablo L. de Miranda <pablolmiranda@gmail.com>
Dfedc33617bd10e9d1b57c1d835f2164?d=identicon&s=25 Pablo L. de Miranda (Guest)
on 2009-04-01 01:39
(Received via mailing list)
Hi Sarah,
I will take a look in the peepcode videos.

Thank you,

Pablo Lacerda de Miranda
pablolmiranda@gmail.com
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2009-04-01 08:50
> http://peepcode.com/products/rspec-basics
> http://peepcode.com/products/rspec-mocks-and-models
> http://peepcode.com/products/rspec-controllers-and-tools
>

I didn't like at all the peepcode episodes on RSpec. You'll have to
rewrite his valid_attributes trick from scratch if your models use
attr_accessible, and some other stuff.

The part about mocking is hard to grasp (although mocking is just such
an easy concept). He uses fixtures, and tests for too many things in the
views.

I don't spec at all the way he shows, I might be doing things wrong, but
I am very happy with my workflow.
Dfedc33617bd10e9d1b57c1d835f2164?d=identicon&s=25 Pablo L. de Miranda (Guest)
on 2009-04-01 14:18
(Received via mailing list)
@Fernando - So what material you recommend to start a study in rSpec?

Att,

Pablo Lacerda de Miranda
pablolmiranda@gmail.com
7b6db606da28bc3876e64f296382dcdd?d=identicon&s=25 Dipen Bhanushali (Guest)
on 2009-04-01 15:25
(Received via mailing list)
Hi All,

I think New user for rspec once need to see the peepcode videos. It is
very
helpful for the starter to understand how the rspec is working. Other
wise
the http://rspec.info documentation is providing the good information
for
any rails developer to use and test it in the application.

Thanks,

Dipen Bhanushali
Complitech Solutions Private Limited
(http://complitech.net)


2009/4/1 Pablo L. de Miranda <pablolmiranda@gmail.com>
994e42bda994be2cd1d791f18ee6d561?d=identicon&s=25 Stephen Eley (Guest)
on 2009-04-01 16:28
(Received via mailing list)
On Tue, Mar 31, 2009 at 11:50 PM, Fernando Perez <lists@ruby-forum.com>
wrote:
>
> I don't spec at all the way he shows, I might be doing things wrong, but
> I am very happy with my workflow.

http://www.kipling.org.uk/poems_neolithic.htm

(The poem's by Rudyard Kipling, if the URL doesn't make it clear.)


--
Have Fun,
   Steve Eley (sfeley@gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine
   http://www.escapepod.org
994e42bda994be2cd1d791f18ee6d561?d=identicon&s=25 Stephen Eley (Guest)
on 2009-04-01 16:42
(Received via mailing list)
2009/4/1 Pablo L. de Miranda <pablolmiranda@gmail.com>:
> @Fernando - So what material you recommend to start a study in rSpec?

1.) The Web site documentation at http://rspec.info

2.) Use it and build experience.

3.) Get the beta of the RSpec book.

4.) Use it and build experience.

5.) Google is your friend.

6.) Use it and build experience.

Finally, if in doubt...  Try using it and building some experience.


--
Have Fun,
   Steve Eley (sfeley@gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine
   http://www.escapepod.org
Eb18ba904f0db0dedf8f08425956c034?d=identicon&s=25 Scott LaBounty (Guest)
on 2009-04-01 17:44
(Received via mailing list)
I've looked at the web site and I guess I'm looking for more examples.
I'd
like to see some simple basic ruby code and then some rSpec code testing
it.
No Rails, no nothing else. I haven't tried the book yet, but there does
not
seem to be a lot of code out there at this basic a level.

Any ideas?

Scott
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2009-04-01 17:48
(Received via mailing list)
2009/4/1 Scott LaBounty <slabounty@gmail.com>:
> I've looked at the web site and I guess I'm looking for more examples. I'd
> like to see some simple basic ruby code and then some rSpec code testing it.
> No Rails, no nothing else. I haven't tried the book yet, but there does not
> seem to be a lot of code out there at this basic a level.
>
> Any ideas?

Try this:

http://blog.davidchelimsky.net/2007/5/14/an-introd...

Cheers,
David
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-04-01 17:50
Pablo L. de Miranda wrote:
> @Fernando - So what material you recommend to start a study in rSpec?
>

This might be heresy, but I suggest that you start with Cucumber and
simply use RSpec matcher syntax in your step definitions.   Once you
have the hang of how to express expectations in the step definitions,
then move on to using RSpec on its own; providing that you still want
to.

I really did not get the hang of any of this, TDD, BDD, Rails or Ruby
until I latched on to Cucumber and started -- very, very poorly mind you
-- to discover how to express behaviour and, more importantly, what
behaviour to express.  It was, for me, a tumultuous journey and one that
I am still traveling.

I am now at the point where, simply by expressing one little bit of
desired bwhaviour in a cucumber scenario, I uncovered a requirement to
leave Rails for a bit and implement a set of SQL triggers.  This would
have been discovered at some point anyway, but I rather suspect that
without BDD the implementation would have been written first in Ruby for
ActiveRecord only to be discarded sometime later when the need for a
trigger became manifest.

Peepcode is good, I have watched and learned lots there.  Just recall
that the episodes go far back in time insofar as Rails and RSpec are
concerned.  These two products have undergone extensive change since
many of the episodes were recorded.
Eb18ba904f0db0dedf8f08425956c034?d=identicon&s=25 Scott LaBounty (Guest)
on 2009-04-01 18:27
(Received via mailing list)
David,

That's more what I was looking for.

Thanks,

Scott
F86901feca747abbb5c6c020362ef2e7?d=identicon&s=25 Zach Dennis (zdennis)
on 2009-04-01 19:02
(Received via mailing list)
On Wed, Apr 1, 2009 at 11:50 AM, James Byrne <lists@ruby-forum.com>
wrote:
> I really did not get the hang of any of this, TDD, BDD, Rails or Ruby
> ActiveRecord only to be discarded sometime later when the need for a
> trigger became manifest.
>
> Peepcode is good, I have watched and learned lots there.  Just recall
> that the episodes go far back in time insofar as Rails and RSpec are
> concerned.  These two products have undergone extensive change since
> many of the episodes were recorded.

Thanks for sharing James. I know when you first joined the list there
were a few frustrating moments, and it's really good to hear about
where you've come and how you've gotten there. This is helpful to both
newbs and seasoned BDDers alike,

--
Zach Dennis
http://www.continuousthinking.com
http://www.mutuallyhuman.com
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-04-01 20:28
Zach Dennis wrote:
>
>
> Thanks for sharing James. I know when you first joined the list there
> were a few frustrating moments, and it's really good to hear about
> where you've come and how you've gotten there. This is helpful to both
> newbs and seasoned BDDers alike,
>

I am very, very grateful for all of the advice and assistance that has
been given to me here.  I am also very grateful for all the tools
provided to me by the community, of which Cucumber and RSpec are
probably most important to me after Ruby and Rails.

I am still making mistakes of course, but now only one of each kind. I
hope.
This topic is locked and can not be replied to.