Listing all specs in a given file

I’m trying to write a simple spec dispatcher, the client-side of which
essentially does the following:

options = Spec::runner::OptionParser.parse( “#{file}”, $stderr,
std_out )
options.line_number = line
Spec::runner::CommandLine.run(options)

Given a spec file and a line number, it’ll run the spec. Simple enough.

My problem is on the server side trying to pull out individual specs
to be run out of a file/series of files. The above code works well if
I pre-populate and array as follows:

queue = [[“spec/one_spec.rb”, 9],
[“spec/one_spec.rb”, 28],
[“spec/one_spec.rb”, 35]]

But I’m having a hard time figuring out how to pull out a list of
examples given a spec filename. Is this parsed at some point before
running, and can I get to that list easily enough?

Thanks for all the help!

Sean

On Mon, Dec 28, 2009 at 10:48 AM, Sean G. [email protected] wrote:

run out of a file/series of files. The above code works well if I
pre-populate and array as follows:

queue = [[“spec/one_spec.rb”, 9],
[“spec/one_spec.rb”, 28],
[“spec/one_spec.rb”, 35]]

But I’m having a hard time figuring out how to pull out a list of examples
given a spec filename. Is this parsed at some point before running, and can
I get to that list easily enough?

I’m not clear on what your goal is here. Can you give a little more
context?
Why do you need a list of examples from a filename?

I’m writing a very simple spec dispatcher, but I want to do it on the
level of examples. I’d like to be able to send individual examples to
my clients, have it run and receive the result back. Currently I can
send a file name and have the entire file run (thus distributing the
rspec tasks at the file-level), but I’m trying to distribute each
individual example out.

Thus if I can get a list of examples from a file along with their line
number, I can put them in a queue and have clients pull them out one
by one.