Rspec error: undefined method `get’
Posted on November 13, 2014
You may have upgraded Rspec recently. Or perhaps a new team member joined, ran bundle
and couldn’t run any controller tests.
The upgrade to Rspec 3 threw a number of us for a loop. Shockingly it wasn’t the hard switch from should
to expect
syntax (although I cried a bit while shoulda matchers were being fixed).
In fact, it was that the Rspec DSL doesn’t do quite so much magic. It doesn’t figure out that you’re in a controller test and give you get
or post
. In fact, it doesn’t figure out you are in a model or view either.
You may have seen an error that looked something like this:
Never fear, Rebecca is here!
Actually, it’s all in the Relish documentation.
Simply add this to your spec_helper.rb
or rails_helper.rb
file:
Got something to say?