[Rspec-devel] Rspec/Test::Unit Integration

Brian Takita brian.takita at gmail.com
Fri Jul 7 00:52:40 EDT 2006


>
> Have you tried test2spec?
> http://rspec.rubyforge.org/tools/test2spec.html


I have not tried test2spec yet. It does look interesting. It looks like it
does its job very well.
I would like to introduce it to my workplace, but going around and
converting all of our tests into specs seems heavy handed. We could have a
pilot project, but it would be nice to just have it work within the context
of our existing tests and libraries.

I was also looking at the converted test and defining helper methods inside
setup seems a bit unintuitive.
It seems strange to have to define your methods inside of the setup block.
Can it be done inside context instead?

When things are inside a Test::Unit::TestCase you still have to use
> the Test::Unit runner, and you won't get the spec commandline goodies.


I'm not too familiar with the command line tools you have now, but they do
look interesting. These tools do seem like a very strong feature.
Pardon me if I'm missing the point, but the tools can read contexts defined
inside a Test::Unit::TestCase by only parsing the file.

Rails fixtures also work with RSpec on Rails.


Unfortunetely it appears that you needed to duplicate code. If you want to
do integration tests, you would need to hook it into RSpec, and the same
goes for Selenium tests.

>From what I understand this patch allows you to use contexts inside
> Test::Unit::TestCase classes.
>
> Are you trying to work on existing Test::Unit::TestCase classes and
> keep them a mix of both test methods and contexts/specs?


Probably not. It's just a proof of concept. I'll email you another patch
with a "better" syntax.

If you really want to stick to the Test::Unit structure, how about this:
>
> require 'test/unit'
> require 'spec'
>
> class MyTest < Test::Unit::TestCase
>   def test_should_allow_shoulds_in_tests
>     (1+2).should_equal 3
>   end
> end


Thats cool. I'm glad you pointed that out.

My point here is that using context and specify inside a
> Test::Unit::TestCase doesn't really buy you that much. Sure, the
> context/specify DSL looks nice, but the real value of this DSL (IMO)
> is the integration with the spec command line and the ability to
> output specdocs with --format specdoc.
> When things are inside a Test::Unit::TestCase you still have to use
> the Test::Unit runner, and you won't get the spec commandline goodies.


Actually it does call runner.add_context(context). This makes it supportable
by the tools, right?

Thanks,
Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-devel/attachments/20060706/96bc62d4/attachment.html 


More information about the Rspec-devel mailing list