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.

--
Andy Lindeman
http://www.andylindeman.com/

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to