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

Ashley Moran ashley.moran at patchspace.co.uk
Fri Aug 6 04:16:15 EDT 2010

On Aug 04, 2010, at 12:41 pm, David Chelimsky wrote:

> What happens if the shared spec author really wants it to just be a hash? Do you think that's a valid use case?

It could get in the way, then, I guess.  You'd always have the original hash parameter if you wanted to use the method, but I guess it could cause trouble if you did this, or similar:

  shared_examples_for "a foo container" do |foo, options = {}|
    it "has a #{foo}" do; end

  describe Bar do
    it_should_behave_like "a foo container", 1, foo: 2

I'll probably play with this idea in my own code.  There's definitely no need worry about it now, being able to pass arguments to shared example groups is 90% of the win for me.



More information about the rspec-users mailing list