I believe this is a missing feature/bug, but when I tried to file an issue (https://github.com/rails/rails/issues/6573) I was told to post it here instead. So, okay, doing my duty! I suspect that nobody will pay any attention to this, and a year from now when someone google''s for this issue this post is going to be all they find, but I''d love to be proven wrong! I believe there is no way using the standard supported Rails testing framework to test routes from an `isolated` engine. Or to test helpers that use these routes. I believe there is no way to test isolated engine helpers or use isolated engine helpers in tests. But I''d be pleased if I''m wrong and I''m just missing something. If you create an isolated engine, then the dummy app has a config/ routes that has for instance mount Widget::Engine => "/widget" If the Widget engines has it''s own config/routes, then ordinarily an app with that line in it would be able to access the engine''s route path helpers as widget.some_path. That works in the app. But it does not work in the test environment. No such method widget, the widget. method isn''t installed in the test environment. The main engine root widget_path => /widget is installed in the testing environment, you can use it in tests and test routing involving that named helper and path. But not any of the specific widget routes that would ordinarily, in an actual app, be available at widget.some_path. Phew, this is confusing to talk about, hope this is understandable. I guess I''ll keep hacking away at it and looking at Rails source, maybe file a pull request if I can figure out what''s going on, but this is very convoluted code, even before you pull the testing environment into it. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, May 31, 2012 at 2:16 PM, Jonathan Rochkind <rochkind-4GNroTWusrE@public.gmane.org> wrote:> Phew, this is confusing to talk about, hope this is understandable.Providing an actual test case that demonstrates the problem would be a lot more effective. :-) -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jonathan Rochkind wrote in post #1062792:> I believe there is no way using the standard supported Rails testing > framework to test routes from an `isolated` engine. Or to test helpers > that use these routes.Jonathan, This is effectively a guess, not knowing your environment or testing situation, but in the case of using rspec and wanting to share your engine''s routes & url_helpers with your dummy app, try adding the line: config.include <YourEngineName>::Engine.routes.url_helpers to the RSpec.configure block in /spec/spec_helper.rb. See Ryan Bigg''s Start Your Engines blog post for details: http://reinteractive.net/posts/2-start-your-engines Look for this paragraph: "Now, these routing helpers aren''t available immediately even still. At the moment, because of how our application is loaded, we''ve only got access to the routing helpers from the dummy application. To gain access to the engine''s routes we must add this line to RSpec.configure in spec/spec_helper.rb: config.include Forem::Engine.routes.url_helpers Hope it helps. -J -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.