I am attempting to make it easier to test Rails engines.
It's helpful that `Rails.application.routes.url_helpers` responds to URL helper methods both on itself or if it's included in a class:
> Rails.application.routes.url_helpers.root_path
=> "/"
> class Foo
include Rails.application.routes.url_helpers
end
=> Foo
> Foo.new.root_path
=> "/"
`MountedHelpers`, which stores helpers for mounted engines, does not do a similar thing ... as demonstrated by the `NoMethodError`:
> Rails.application.routes.mounted_helpers.railsengine
NoMethodError: undefined method `railsengine' for
ActionDispatch::Routing::RouteSet::MountedHelpers:Module
from (pry):20:in `block (2 levels) in <top (required)>'
> class Foo
include Rails.application.routes.mounted_helpers
end
=> Foo
> Foo.new.railsengine
#<ActionDispatch::Routing::RoutesProxy:0x007fc86e85c6c0
@routes=#<ActionDispatch::Routing::RouteSet:0x007fc869c31e80>,
@scope=...
>
Would you welcome a pull request to `extend self` in `MountedHelpers` so it could be delegated directly to?
Then, in a test harness (for instance, in an RSpec routing spec), we could delegate directly to `MountedHelpers`. Otherwise, we'd have to construct an object solely to hold the mounted helpers. The setup for this might be pretty awkward.