[Rspec-devel] Advice Needed

Scott L Holmes scottlholmes at gmail.com
Fri May 5 07:48:02 EDT 2006

Nothing worse in a forum than a question with no answer, so I'll update this
with my progress:

require 'spec'
context_runner = Spec::Runner::ContextRunner.new(["-v"],[nil])
Spec::Runner::Context.context_runner = context_runner

Hopefully, there's no adverse side affects for initializing the runner with
an empty filename array. So, far so good.

By associating the context_runner with the class Spec::Runner::Context, we
can created new Context objects and they'll be automatically be added to the
runner. Given this (and a database reader thing), we add contexts to the
runner thusly:

context = Spec::Runner::Context.new(dbthing.get_context_name) do
 eval("setup {#{dbthing.get_context_setup_block_text}}")
 dbthing.get_specifies.each {|specification|
   eval("specify('#{specification.get_specify_name}') {#{
 eval("teardown {#{dbthing.get_context_teardown_block_text}}")

I need to come up with a straight forward approach to translating Ruby Code
stored in a String into a block so that I could just do this

setup dbthing.get_context_setup_block_text.to_block

I've not been able to find anything on the web yet that gets me there and
I'm too new to Ruby to make the connections on my own.

Anyway, we can run the whole thing by running the runner:



On 5/3/06, Scott L Holmes <scottlholmes at gmail.com> wrote:
>  I've been looking at rspec for some time now. I like very much your
> methodolgy and the code is top-knotch.
> I would like to incorporate rspec in an environment that I'm building for
> JRuby. So far so good. At minimum, the context and their specifications
> would be stored in sort of a knowledgebase - so instead of:
> $ spec stack_spec.rb
> I have more like:
> ProjectSpecification.new("stack_spec").execute
> ProjectSpecificiation merely retrieves the contexts and specs from the kb
> and then (somehow?) submits them to spec. Right now, I'm just constructing a
> simple context and using eval to "run" it.
> Now what I don't want to do is code myself in a corner - eventually, I'd
> like to be able to make use of the runners and reports you have. Can you
> make suggestions for future-proofing my environment which merely seeks to
> "store" rspecs? Sorry, I'm only just getting started on rspec's API - is
> there a point in the api you can steer me to (it's quite dense).
> Appreciate your time. You're system is phenomenal - paradigm shifting
> really - very well done.
> Scott L Holmes
> http://www.slholmes.org/ <= more clues about what I'm doing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-devel/attachments/20060505/17cda3b5/attachment.htm 

More information about the Rspec-devel mailing list