[rspec-users] Evaluating shared example customisation block before shared block

David Chelimsky dchelimsky at gmail.com
Fri Jul 30 20:10:07 EDT 2010

On Jul 30, 2010, at 6:56 PM, Myron Marston wrote:

> On Jul 30, 2:58 pm, Ashley Moran <ashley.mo... at patchspace.co.uk>
> wrote:
>> On 30 Jul 2010, at 5:00 PM, David Chelimsky wrote:
>>> By all means.
>> I've started on that and filed a ticket[1].
>> One question I have, is I keep calling the Example Group that uses a shared block the "host group".  Is there already a name for it?  I never know what to use, and I'm not sure "host group" describes it accurately anyway.
>> Cheers
>> Ash
>> [1]http://github.com/rspec/rspec-core/issues/issue/99
>> --http://www.patchspace.co.uk/http://www.linkedin.com/in/ashleymoran

> I may be the only one who finds this useful, but I think there's value
> in evaluating the customization block after the shared example group
> block.  It allows the shared example group to provide a default
> implementation of a helper method, and then an instance of the shared
> behavior to override the helper method if appropriate.  If you
> evaluate the customization block before the shared example group
> block, the default implementation wins out, and you have no way to
> override helper methods in an instance of a shared example group.

You can still get the same outcome, but you have to implement it in the group like this:

unless defined?(:foo)
  def foo; "foo"; end

I think it's a good trade-off to put that burden on the group (and it's author) rather that the consumers of the group.

More information about the rspec-users mailing list