Why do I get "undefined method or variable 'example'" in RSpec 3.0?

Viewed 4328

After upgrading to RSpec 3.0, I got the following message:

 Failure/Error: Unable to find matching line from backtrace
 NameError:
   undefined local variable or method `example' for #<RSpec::ExampleGroups::Anonymous:0x007f9ae985b548>

The message persisted even after reducing the spec to the following:

describe "" do
  it "" do
  end
end

I did notice capybara was near the top of the stack, as follows:

 # /Users/palfvin/.rvm/gems/ruby-2.0.0-p247@botmetrics/gems/capybara-2.1.0/lib/capybara/rspec.rb:20:in `block (2 levels) in <top (required)>'

in case that helps.

5 Answers

This error results from installing RSpec 3.0.0.beta while continuing to run Capybara 2.1.0. If you install Capybara 2.2.0.beta, the error will go away.

Related