Topic: RSpec vs Baked in Testing

I've been using Rails on and off for about 18 months now, mostly to develop simple intranet apps.  I'm getting ready to attempt larger apps and maybe some websites.  Up until now I have not used any kind of testing.  I completely agree that it is essential and I want to do it from this point on in all my projects.

  Having said that, what is RSpec?  Without looking into it at all I assumed that it was a compliment  to the existing Rails tests.  I did a little reading about it today and now I'm starting to think that it's an alternative to Rails tests.  Is that true?  If so, am I better off spending my time learning RSpec?  Right now I know very little about RSpec and Rails tests.  I would like to just learn one at first and have that be the one that will help me most.

  Thanks for your thoughts.

Re: RSpec vs Baked in Testing

RSpec is, as you correctly guessed, an alternative to the "baked-in" testing.

RSpec produces more readable tests like so:

describe Blog, "in general" do
it "should always have a title" do
@blog =
@blog.text = "Here's some text!" be_false
@blog.title = "Title!" be_true

It gives something that your boss should be able to read with very little understanding of Rails (mine understands it)

It's also nicer to write. If you're a beginner I would suggest to use RSpec testing instead of the baked in one.

Although RyanB's screencast on testing without fixtures uses the baked in testing, it shows you how to test without those nasty fixtures which should also help you along the way.

Re: RSpec vs Baked in Testing

Thank you sir.  I shall take the RSpec road.

Re: RSpec vs Baked in Testing

Going the RSpec road is basically "BDD", which is something that I recommend strongly to do as a programming pattern.

Check it out, live it, breathe it, and become the best smile

Last edited by DFischer (2007-09-05 20:12:42) - Personal Web-Technology-Blog, Los Angeles.

Re: RSpec vs Baked in Testing

Peepcode has a good series on rSpec which I recommend.

Railscasts - Free Ruby on Rails Screencasts