[rspec-devel] Trying to figure out how the it_should_behave_like "sandboxed rspec_options" works

Matt Patterson matt-lists at reprocessed.org
Wed Jul 9 17:24:40 EDT 2008


Hey all

I've had a bit of time to develop the start I made on ticket 373 over  
at lighthouse: http://is.gd/Px9. I started to swap in an analogous  
system to the stubbable separate spec collector for options. The rough  
idea is that you'd then just stub out Spec.options and return a  
sparkly new Spec::Runner::Options object instead of the  
it_should_behave_like "sandboxed rspec_options" global variable swap.  
So far so good, but I started to see sample example groups from the  
specs (i.e. @example_group = Class.new(ExampleGroup} { describe('does  
nothing'); it("should do x") { x.should == y } }) being run and  
reported as failures by the main spec run. Clearly, something's  
leaking out...

Worse than that, the specs for a _spec.rb file got run, but the output  
said 0 specs, 0 passed. There was still plain text formmatter output,  
but my guess is that was from my stubbed Spec::Runner::Options which  
fell back to progress format and no ANSI color...

Notionally, there was a pretty simple swap - Spec.options - a function  
lifted from rspec_options in all but its use of a global variable,  
plus stubbing it where the sanboxed rspec_options trick had been used  
before was having radically different effects. Which means that my  
understanding of that part of the system is really flawed, I guess...

Would someone be willing to talk me through the way that Spec  
collection and the describe class creation stuff really works? In  
return I promise to draw pictures of it and write it up. I'll also try  
and fix some of the tedious long-lived bugs (like typos and stuff) to  
reduce the open bug count in lighthouse...

Thanks!

Matt

-- 
   Matt Patterson | Design & Code
   <matt at reprocessed org> | http://www.reprocessed.org/





More information about the rspec-devel mailing list