This is an attempt at implementing #792. It allows shared_examples to be defined per ExampleGroup in order for keys to be safely reused.

It was more challengeing than it appeared due to the need to:

  1) Inherit examples from outer context groups
  2) Allow examples to be defined in main!

The issues I can see with this attemp are:

Extra methods being defined on main and thus Object.
Having to refactor the specs to make it pass, as the specs often defined things within the context of a test, but used them on a different context (an example group normally), the old global behaviour allowed this but the new context specific behaviour didn't.

Some ideas I could refactor towards:
  Try to pull the examples into a hash lookup in Registry
  Redefine how these are mixed into main so that examplegroups has different behaviour to main

There is probably stuff I've not thought of to do with RSpec's nested context class system thing...

Thoughts?