Merge pull request #35175 from drn/create-session
Support testing of non-ActionDispatch-routed apps.
This commit is contained in:
commit
2edeb438e6
@ -335,7 +335,7 @@ def create_session(app)
|
||||
klass = APP_SESSIONS[app] ||= Class.new(Integration::Session) {
|
||||
# If the app is a Rails app, make url_helpers available on the session.
|
||||
# This makes app.url_for and app.foo_path available in the console.
|
||||
if app.respond_to?(:routes)
|
||||
if app.respond_to?(:routes) && app.routes.is_a?(ActionDispatch::Routing::RouteSet)
|
||||
include app.routes.url_helpers
|
||||
include app.routes.mounted_helpers
|
||||
end
|
||||
|
@ -0,0 +1,27 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "abstract_unit"
|
||||
|
||||
module ActionDispatch
|
||||
module Routing
|
||||
class NonDispatchRoutedAppTest < ActionDispatch::IntegrationTest
|
||||
# For example, Grape::API
|
||||
class SimpleApp
|
||||
def self.call(env)
|
||||
[ 200, { "Content-Type" => "text/plain" }, [] ]
|
||||
end
|
||||
|
||||
def self.routes
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
setup { @app = SimpleApp }
|
||||
|
||||
test "does not except" do
|
||||
get "/foo"
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user