Read more

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

Daniel Straßner
December 05, 2019Software engineer at makandra GmbH

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!

Illustration money motivation

Opscomplete powered by makandra brand

Save money by migrating from AWS to our fully managed hosting in Germany.

  • Trusted by over 100 customers
  • Ready to use with Ruby, Node.js, PHP
  • Proactive management by operations experts
Read more Show archive.org snapshot

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
Posted by Daniel Straßner to makandra dev (2019-12-05 11:40)