RSpec NoMethodError: "undefined method `describe' for main Object"

The problem:

You can tell from the error message "undefined method `describe' for main Object" that the underlying problem is that you are trying to call describe on the the basic Object main, which does not have a describe method.

The solution:

Call RSpec.describe instead of just describe.

require 'rspec'
require './RubyOffRailsTuts/classes/furlong'

RSpec.describe Furlong do
end

Alternative to prefacing describe as RSpec.describe, you can add

config.expose_dsl_globally = true

to your spec_helper.rb.

Tags:

Ruby

Rspec