RSpec Application Helper Test: Undefined local variable or method `helper`
I created a new Rails project with a fresh RSpec installation, and it led me to the problem. Apparently one of the recent betas introduced a configuration directive called config.infer_spec_type_from_file_location!
that was missing from my slightly older spec_helper
file; without it, RSpec wasn't guessing the spec type and mixing in the associated methods. Beware breaking changes!
add :type => :helper
so your code should look like
describe ApplicationHelper, type: :helper do ...end
That's a weird error !! are you sure you required spec_helper
in your spec ?
Anyway you could try without the helper
method:
First you should first add to /spec/spec_helper.rb
the following:
RSpec.configure do |config| ... config.include ApplicationHelperend
Then test without helper
, so it will be:
describe ApplicationHelper do it 'renders Markdown from plain text' do plaintext = '# Header' expect(md(plaintext)).to eq("<h1 id=\"header\">Header</h1>\n") endend