Monday, September 18, 2006

Going rSpec

After played with rSpec for a while, I have decided to convert BuildMaster on top of it. However, the test2spec script did not work for the project, so after a few experiment, the following regular expression helped me converting the majority of the syntax. I still had to convert the class definition to context definition manually, though.

1. Converting assert_equal(a, b) to b.should_equal a

replace "assert_equal\(([^,]+),\s*([^\n]+)\)" with "$2.should_equal $1"

2. Converting "test_..." methods to "specify ..."

replace "def test_([^\s]+)" to "specify '$1' do"

2 comments:

David Chelimsky said...

Thanks for plugging rspec. What problems did you have w/ test2spec?

David

Shane said...

It didn't say much. Just something like "failed to convert ... file"

I didn't know you were watching ThoughtBlog. Good thing that I didn't ramble on too much on rSpec.