Created
March 24, 2016 17:34
-
-
Save tsyber1an/7b391995cbbb611097e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MultiAppHandler | |
def initialize(default_app, extra_app) | |
@default_app = default_app | |
@extra_app = extra_app | |
end | |
def call(env) | |
request = Rack::Request.new(env) | |
extra_app_routes = @extra_app.routes[request.request_method] | |
if extra_app_routes.present? && extra_app_routes.any?{ |pattern, keys, conditions, block| pattern.match(request.path_info) } | |
app = @extra_app | |
else | |
app = @default_app | |
end | |
app.call(env) | |
end | |
end | |
original_app = Capybara.app | |
Capybara.app = MultiAppHandler.new( | |
original_app, | |
Rails2App | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment