Converting Test::Unit to Shoulda

1 view
Skip to first unread message

Sean Hussey

unread,
Apr 16, 2008, 1:55:17 PM4/16/08
to sho...@googlegroups.com
Hi everyone,

I swear I remember seeing (and using) a script or rake task that
converted Test::Unit based test files to a shoulda context. I can't
find even a mention of it anywhere, so maybe it was all a beautiful
dream. Does this sound familiar to anyone else? Do you know where I
can find it?

Thanks!

Sean

Ken Collins

unread,
Apr 16, 2008, 2:42:28 PM4/16/08
to sho...@googlegroups.com

I had this dream too, but like you cant find it.

Tammer Saleh

unread,
Apr 17, 2008, 7:45:42 AM4/17/08
to sho...@googlegroups.com
Hey Guys,

Indeed, it wasn't a dream!

There is a script to convert between test::unit and shoulda syntax,
and I've been meaning to check it over for bugs and add it to the
documentation. It's in the git repository, so you should have it as
vendor/plugins/shoulda/bin/convert_to_should_syntax. Here's the link
in git:

http://github.com/thoughtbot/shoulda/tree/master/bin/convert_to_should_syntax

As usual, please feel free to file a lighthouse ticket, or make a git
branch with fixes if you find problems with the script. It should
probably be converted to a rake task at some point.

Cheers,
Tammer

Sean Hussey

unread,
Apr 17, 2008, 12:16:24 PM4/17/08
to shoulda
First, thanks!

Second, best error message I've seen in a while: "This system doesn't
have a /tmp directory. wtf?"

Third, I submitted a Lighthouse ticket for one of the gsubs that blew
away some test definitions.

Fourth, thanks again!

Sean

On Apr 17, 7:45 am, Tammer Saleh <tsa...@gmail.com> wrote:
> Hey Guys,
>
> Indeed, it wasn't a dream!
>
> There is a script to convert between test::unit and shoulda syntax,  
> and I've been meaning to check it over for bugs and add it to the  
> documentation.  It's in the git repository, so you should have it as  
> vendor/plugins/shoulda/bin/convert_to_should_syntax.  Here's the link  
> in git:
>
> http://github.com/thoughtbot/shoulda/tree/master/bin/convert_to_shoul...

Tammer Saleh

unread,
Apr 18, 2008, 9:03:28 AM4/18/08
to sho...@googlegroups.com
And here's another version of the script with some improvements:

* it runs the tests before and after, making sure the test count is
the same
* it fixes the bug mentioned below
* it runs for multiple files

http://pastie.caboo.se/182911

When I get a chance (or when some kind volunteer does), it should be
converted into a rake task so that it's documented and easy to use.
Something like "rake shoulda:convert_files FILES=test/unit/*.rb"

Tammer

Reply all
Reply to author
Forward
0 new messages