spec_converter released
Tired of converting your Test::Unit tests over to test/spec specs by hand? So were we. So we made it as easy as 1,2,3:
sudo gem install spec-converter
cd ~/work/my_project
spec_converter
Note that it works on files in place, so be sure to check in or backup first!
It only does the basics right now, converting old style specs to new(context with describe, spec with it) and things like:
def setup
@o = Object.new
end
def test_should_do_something_cool
assert_equal 1+1, 2
end
to:
before do
@o = Object.new
end
it "should do something cool" do
assert_equal 1+1, 2
end
See its spec for a full list of features. If you'd like to grab the latest, get it at the subversion repository.

2 comments:
Thx, worked pretty welcome. The only changes were: adding gem 'test-spec'; require 'test/spec', and for any test classes that used the newer Rails 2.0 Test::Unit::TestCase subclasses - ActiveSupport::TestCase and ActionController::TestCase - I needed to manually convert them into describe blocks and add back in the setup functionality.
Cool tool, it was what I was looking for. Too bad it doesn't work properly yet in some cases.
Some strange things I found:
- assert users(:any).update_attributes(:location => 'Raccoon City')
+ users(:any).update_attributes(:location .should => 'Raccoon City')
And custom error messages for tests are done wrong when no parenthesis were used:
- assert_not_nil goal.errors.on(a), "Should give error on #{a}"
+ goal.errors.on(a), "Should give error on #{a}".should.not == nil
Otherwise it works fine! Keep up the good work!
Post a Comment