When developing a project, I turned to shoulda for testing just because it's what I was familiar with. However, the project hasn't had a release in over a year. I'm wondering if anyone has recommendations on alternatives, or if I should just stick with shoulda?
-
3Aren't the alternatives 'Woulda' and 'Coulda'? :D – Jonathan Leffler Feb 20 '12 at 01:08
2 Answers
The remarkable gem is the closest I've found to Shoulda. Unfortunately it looks like it hasn't been updated in even longer. It also relies on RSpec and it not compatible with Test::Unit.
It isn't clear to me how well it supports Rails 3 - although there are some instructions for getting it up and running.
After looking into both Shoulda and Remarkable I decided to go with Shoulda as it still seemed the more likely set of helpers to be updated.
One of the issues you will have with shoulda is that Thoughtbot uses RSpec rather than Test::Unit, which is part of the reason that the Shoulda gem (which exists for the benefit of Test::Unit users) has seen little activity - the RSpec component of the gem, shoulda-matchers, has been updated much more recently. Thoughtbot also found a new maintainer for shoulda-contextin Jan 2012 (this is the gem required alongside shoulda-matchers to get everything working in Test::Unit - the shoulda gem really only pulls in shoulda-matchers and shoulda-context) so there should be more focus on the Test::Unit side moving forward I expect.
Hopefully these moves give at least a little confidence that Shoulda for Test::Unit will be updated more frequently moving forward. In the absence of any other suggestions I would stick with Shoulda for the time being.

- 9,454
- 3
- 45
- 34
-
Thanks for the explanation. Hopefully we'll see some much-needed movement on the shoulda releases with the changes you mentioned! – Matt Huggins Feb 20 '12 at 14:18
Rspec is the most common BDD framework used for testing in ruby and is quite popular. It works well with shoulda assertions in case u like some of the assertions in shoulda. Ruby also ships by default with test/unit for testing. Between, what are the issues you have with shoulda at the moment?

- 1,041
- 6
- 9
-
I know of rspec, but this post made it sound like they're not alternatives, but more complementary: http://stackoverflow.com/questions/4609543/rspec-and-shoulda-complementary-or-alternatives – Matt Huggins Feb 20 '12 at 00:02
-
Yes, you can use shoulda assertions straight into rspec. You could also configure to use mocking using shoulda. So yeah, they are complimentary. Shoulda is quick and helpful in adding assertions for validations. – Kunday Feb 20 '12 at 00:05
-
You can add shoulda matchers by defining gem 'shoulda-matchers' in your Gemfile – Kunday Feb 20 '12 at 00:06