module RSpec::Rails::ControllerExampleGroup
def bypass_rescue
end
end.to raise_error(/403 Forbidden/)
get :show, id: profile.id + 1
bypass_rescue
expect do
login_as profile.user
profile = create_profile
it "raises a 403 when a non-admin user tries to view another user's profile" do
describe ProfilesController do
@example
conditions.
specify that an action _should_ raise an exception given appropriate
`rescue_with_handler` to raise the exception passed to it. Use this to
Extends the controller with a module that overrides
def bypass_rescue controller.extend(BypassRescue) end
def method_missing(method, *args, &block)
If method is a named_route, delegates to the RouteSet associated with
def method_missing(method, *args, &block) if route_available?(method) controller.send(method, *args, &block) else super end end
def route_available?(method)
def route_available?(method) (defined?(@routes) && route_defined?(routes, method)) || (defined?(@orig_routes) && route_defined?(@orig_routes, method)) end
def route_defined?(routes, method)
def route_defined?(routes, method) return false if routes.nil? if routes.named_routes.respond_to?(:route_defined?) routes.named_routes.route_defined?(method) else routes.named_routes.helpers.include?(method) end end
def routes=(routes)
- Private: -
def routes=(routes) @routes = routes assertion_instance.instance_variable_set(:@routes, routes) end