Skip to content

Don't add `describe` to every object.

gitlab-qa-bot requested to merge limit_monkey_patching_of_describe into master

Created by: myronmarston

Instead, make it only available on:

  • The main object--so it can be used at the top level.
  • Modules--so example groups can be declared nested within modules, as is the common practice.

Besides this, the only other place we need describe is from within example groups (so we can nest them), and this is taken care of by RSpec::Core::ExampleGroup.describe.

I got the idea for this from a recent change in Sinatra that similarly limits the DSL to just the main object rather than all objects:

https://github.com/sinatra/sinatra/commit/46bdb7dcf842afdb3bce57a6753eb4d909b1225d

There is some risk to this change, since it is removing describe from lots of objects it was available on previously, but users shouldn't be calling #describe on any object willy-nilly, anyway. The rspec-expectations and rspec-mocks specs pass with this change (as well as the rspec-core specs, of course).

Thoughts?

/cc @dchelimsky @patmaddox @alindeman @justinko @spicycode

Merge request reports