Paths not defined in ancillary specifications

I just upgraded Rails version from 4.2.6 to 5.0.0.rc1 and used RSpec version 3.5.0.beta4 .

Problem: I have a method that calls root_path in my helper, and the paths are not defined in the helper specifications. The problem started after updating the version.

I get the following error when starting my helper specification;

 NoMethodError: undefined method `root_path' for #<#<Class:0x00000002749080>:0x00000011f3e650> 

I tried adding the following line to my assistant;

 include Rails.application.routes.url_helpers 

But now the error is as follows:

 NameError: undefined local variable or method `default_url_options' for #<#<Class:0x00000001efa550>:0x0000001784ccd8> 

How can I define path helpers for helper specs or default_url_options?

+6
source share
1 answer

It seems like it could be a bug with RSpec, one thing you can do in your helper specifications is to add the necessary methods yourself.

 describe MyHelper do context "doing something" do helper do include Rails.application.routes.url_helpers def default_url_options {} end end it "should work" do expect(helper.run_it).to be_truthy end end 
0
source

All Articles