Rspec 3: what to do when `describe` is undefined

Updated . Posted . Visible to the public.

When tests might not run with skipping RSpec in the RSpec.describe failing with the error undefined method 'describe' for main:Object this card will help you out!

In RSpec 3 the DSL like describe is exposed globally Show archive.org snapshot by default. Therefore it is not necessary to write Rspec.describe.

However, there is a config option to disable this beavior, which also disables the old should-syntax:

RSpec.configure do |config|
  config.disable_monkey_patching!
end

In order to still use describe without Rspec, you can set expose_dsl_globally = true after disable_monkey_patching!:

RSpec.configure do |config|
  config.disable_monkey_patching!
  config.expose_dsl_globally = true
end
Daniel Straßner
Last edit
Felix Eschey
Keywords
omit, discard, skip
License
Source code in this card is licensed under the MIT License.
Posted by Daniel Straßner to makandra dev (2019-12-05 10:40)