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 web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
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)