[rspec-users] Evaluating shared example customisation block before shared block
Ashley Moran
ashley.moran at patchspace.co.uk
Mon Aug 2 09:16:33 EDT 2010
On 2 Aug 2010, at 2:04 AM, Myron Marston wrote:
> I actually find the use of this to be a bit confusing:
>
> [:foo, :bar].each do |arg|
> it_should_behave_like "Something", arg do |a|
> # The value of the param is already bound to arg and now it's
> bound to a, too.
> end
> end
>
> I suppose it may be useful in some situations, so I'm fine with it as
> long as the implementation allows you to skip the `|a|`:
>
> [:foo, :bar].each do |arg|
> it_should_behave_like "Something", arg do
> # no need to declare the |a| parameter since we already have it in
> arg.
> # I find this to be less confusing.
> end
> end
Agreed - requiring the block parameter to be declared in the host group is putting the onus back on the user, not the author, of the shared examples. I think we need a way to implement the second version.
Ash
--
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran
More information about the rspec-users
mailing list