I have rspec specification:
require "spec_helper"
describe ApplicationHelper do
describe "#link_to_cart" do
it 'should be a link to the cart' do
helper.link_to_cart.should match /.*href="\/cart".*/
end
end
end
And ApplicationHelper:
module ApplicationHelper
def link_to_cart
link_to "Cart", cart_path
end
end
This works when visiting a site, but the specifications do not work with RuntimeError that routing is unavailable:
RuntimeError:
In order to use #url_for, you must include routing helpers explicitly. For instance, `include Rails.application.routes.url_helpers
So, I included Rails.application.routes.urlin my spec, the spec_helperfile, and even myself ApplicationHelper, but to no avail.
Edit: I run tests through spork, maybe this is due to it and causing the problem.
How do I enable these route assistants when working with Spork?
source
share