Last Updated: April 16, 2018
·
2.754K
· mixandgo

ApplicationController methods/helpers from rspec

Here's a tiny snippet that will save you some headaches when trying to access a protected ApplicationController method or a helper method (i.e. one that's defined in ApplicationController with helper_method :foo) from an rspec controller spec.

class ApplicationController < ActionController::Base

  protected

  def my_special_url()
    "/special-url"
  end
  helper_method :my_special_url

end
controller.view_context.my_special_url()