[rspec-users] driving rspec from a Ruby script

Ed Keith lists at ruby-forum.com
Sat Jan 17 09:48:39 EST 2009

Ashley Moran wrote:
> On 16 Jan 2009, at 17:44, Ed Keith wrote:

> You don't provide enough information for me to be sure, but what you
> describe sounds sufficiently high-level enough to make Cucumber[1]
> worth looking into.
> If you search the archives of this list I posted a very bad example of
> using Cucumber to spec binaries written in other languages (I used
> sort, I think).
> Ashley
> [1] http://wiki.github.com/aslakhellesoy/cucumber
> --
> http://www.patchspace.co.uk/
> http://aviewfromafar.net/
> http://twitter.com/ashleymoran

I looked at Cucumber, I'm not clear on what it does, but I do not think 
it is what I need.

Going into the details: I am testing a C++ library. There are many test 
classes to test different aspects of the library. Some of the test cases 
as supposed to fail to compile when the library is misused. At first I 
used ruby to run the compilers and check the return value against 0 for 
success. For the tested that were supposed to fail to compile, that was 
all I needed. For the tests that were supposed to work I then ran the 
generated executable and tested the return value. So far everything is 

The library is supposed to be portable. So I am testing it with several 
different compilers on several different operating systems. I do not 
want to put platform specific information into the RSpec files, so I 
wrote shell scripts of Unix and batch files on windows to set up the 
environment for each compiler and then call RSpec with each 
configuration environment. Now I have two problems: 1) Batch language is 
real pain to do anything nontrivial in; 2) I have two sets of driver 
scripts to maintain.

I should be able to solve both problems by using a portable scripting 
language for the driver scripts. My first thought was to use Python, 
since I know it. This will work, but there are two things that make me 
think it is suboptimal: 1) It will require that Python be installed on 
all test systems; 2) It will require that the python interpreter invoke 
the Ruby interpreter, this is very inefficient, not to mention ugly.

I can easily solve the first problem by writing the driver scrips in 
Ruby since Ruby must be installed to run RSpec, and I intended to learn 
Ruby eventually anyway. My first, naive, attempt works, but I am running 
the ruby interpreter inside the ruby interpreter recursively when I call 
RSpec ("system spec spec1.rb"). There must be a better way to invoke 
RSpec without recursively invoking the Ruby interpreter.

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list