Default Test library

Along the same lines as the default javascript library discussion [1],
why don't we switch the default test library to RSpec? The stats [2]
posted by Xaviar in the other thread seem to support that RSpec is the
preferred way to test.

[1] http://groups.google.com/group/rubyonrails-core/browse_thread/thread/e9b9cf2233d9a59b
[2] http://survey.hamptoncatlin.com/survey/stats

Just for endorsing the stats, I'm one of those Rspec users :slight_smile:

Rodrigo.

So am I.

And every client project I've worked on for the past three years has
used RSpec, whether that's been my choice or not. More often not.

Also along the same lines as the JS discussion, I think this is a good thing to talk about for 3.1. Let’s let the core team focus on getting 3.0 out the gate first, they’re too close to a release to get bogged down in an issue that will surely arouse a lot of impassioned opinions.

-Norman

Even Shoulda is switching focus to RSpec [1].

[1] http://robots.thoughtbot.com/post/701863189/shoulda-rails3-and-beyond

I am one of the majority who prefer RSpec over Test::Unit.

I’ve been using RSpec since June 2007 and I’ve definitely grown familiar with it and prefer its syntax. I definitely prefer RSpec’s way of running a single test: spec :.

I can see 2 major concerns that will be raised during this debate.

  1. “It’s already working, why change it?” - I think this has been answered already: The community prefers RSpec. The Rails tests were written in Test::Unit because that’s all there was. Now there’s a multitude of frameworks out there and it just so happens that RSpec appears to be the favourite. By using RSpec, you’re lowering the barrier of entry to those who have only ever used RSpec and RSpec’s syntax (@some.complex.thing.should eql(2)) is not as ambiguous as Test::Unit’s assert_equal, which is backwards imo. Sure, syntax is just details, but details are important.

I can’t point out any particular massive SVN-to-Git-like changes the switch to RSpec would bring, but this is probably something other people can bring up and point out. I can think of two though: easier-to-understand output and proper Hash diffing (“hash1 contains key ‘blah’, hash2 doesn’t”, rather than a diff which was not made for Hashes, but Strings).

  1. “It’ll be a mammoth effort to switch over!” - To those who raise this point: if you don’t want to help, then don’t. I’m sure if there were enough people working on converting the tests over to RSpec then it won’t be a problem for you personally. You’ll just have to learn something new (if you didn’t know RSpec already). If your adverse to that then you probably shouldn’t be doing web dev.

I am all for this change over, but unfortunately I do not have the time to assist on any meaningful scale above (pun alert!) “spectator”. I think what’ll need to happen is that a group of dedicated people will need to work together on converting this over after the core’s “blessing”. I think that Yehuda would be for it, but to convince the other Higher Ups may prove troublesome. Careful of their fragile egos. I must mention again that this won’t take a day. A week. It’s probably something more like a month of medium-to-hard work, head-scratching and omgwtf’ing. Be prepared.

People prefer RSpec, and I think Test::Unit’s time is up.

It’s time for a change.

I think the discussion was actually about changing the default test
library used by generators in Rails applications, not the test
framework that Rails itself uses.

Bah. This is what I get for reading emails too early in the morning. Switching over to using RSpec is such an easy task now with Rails 3 that the thought didn’t occur that that’s what this was about. The steps are (I assume a bare-bones app):

rm -rf test

Add gem ‘rspec’, 2.0.0.beta11’ to the Gemfile

bundle install

rails g rspec:install

omg done.

Still, my comments make some sense right? Just in a different, not-yet-existing context.

Bah. This is what I get for reading emails too early in the morning.
Switching over to using RSpec is such an easy task now with Rails 3 that the
thought didn't occur that that's what this was about. The steps are (I
assume a bare-bones app):
rm -rf test
Add gem 'rspec', 2.0.0.beta11' to the Gemfile
bundle install
rails g rspec:install
omg done.
Still, my comments make some sense right? Just in a different,
not-yet-existing context.

For sure - definitely an idea worth considering and discussing.