[rspec-users] RSpec interacting with Test::Unit: weird "is already defined" error
dchelimsky at gmail.com
Tue Nov 30 15:39:29 EST 2010
On Nov 30, 2010, at 2:11 PM, Jo Liss wrote:
> On Tue, Nov 30, 2010 at 7:21 PM, David Chelimsky <dchelimsky at gmail.com> wrote:
>> Or is there a problem you're trying to solve by intermingling them?
>> I'd recommend keeping specs under the spec directory and run them separately from Test::Unit tests.
> Ah, I see -- thanks for the quick reply!
> So, I'm really trying to write test code, not specs. There are a
> bunch of existing Test::Unit tests. But since I'm using
> rspec/expectations's "should" assertions in my test code already (as
> described on http://relishapp.com/rspec/rspec-expectations/v/2-0/dir/test-frameworks/test-unit-integration
That page only applies to rspec-expectations (should + matchers), not rspec-core, which provides the structure.
> ), I figured I might use RSpec instead of Test::Unit to structure my
> tests, as RSpec has this awesome nesting feature.
Yes, it does, which is why I like to use rspec for the whole thing :)
> But from your reply I take it that trying to squeeze my test code into
> RSpec (even if I migrated all my Test::Unit tests to RSpec tests) is
> going to result in ugly code and unhappiness?
Not necessarily. Depends on how you go about it. Also depends on what environment you're already in.
There is a project called rspec-unit that can help you migrate from test/unit to rspec gradually, but it doesn't always work well if you're using test/unit extensions that hack into test/unit internals. Might want to take a look at it, however:
More information about the rspec-users