[rspec-users] Issue with parameterized shared example group on ruby 1.8.6

Ashley Moran ashley.moran at patchspace.co.uk
Fri Aug 20 03:33:18 EDT 2010

On 20 Aug 2010, at 06:40, Myron Marston wrote:

> describe VCR::HttpStubbingAdapters::FakeWeb do
>  it_should_behave_like 'an http stubbing adapter', ['net/http'],
> [:method, :uri, :host]
> end
> describe VCR::HttpStubbingAdapters::WebMock do
>  it_should_behave_like 'an http stubbing adapter', %w[net/http patron
> httpclient em-http-request], [:method, :uri, :host, :body, :headers]
> end

Neat! I'm interested to see applications of parameterised shared examples. I'd certainly never thought of defining optional features in that way.

> So...how should we deal with this?  A few ideas come to mind:
> 1.  Find a better way to fake module_exec on ruby 1.8.6.  I'm not sure
> if this is even doable.
> 2.  Leave things as they are...but I don't like this idea since the
> error message is fairly cryptic.
> 3.  Rescue the error and raise a more clear error message.
> 4.  Rescue the error and print a warning.
> I lean towards #4, because the #module_eval is only necessary to
> extract the instance method definitions. 

4 makes sense to me iff the code does actually run correctly in all circumstances, otherwise I'd lean towards 3.



More information about the rspec-users mailing list