Defining methods inside RSpec.configure blocks still defines them on Object. Use config.include with a module to define these only in the specs and not globally. For matcher methods, define them in RSpec::Matchers::DSL::Matcher. Change rubocop config to allow this inside of the RSpec.configure blocks (technically, any constant inside any block). Add an Object.method_added hook that raises an exception if defining a method on object, other than Nokogiri, which is defined by the nokogiri gem. This will result in the specs raising an error without executing anything if you attempt to define a method on Object.
1.6 KiB
1.6 KiB