When I mount an engine in config/routes.rb like so: mount Blog::Engine => "/blog" I''d like to be able to test that the routing is there. I added assert_mounts to ActionDispatch::Assertions::RoutingAssertions (https://gist.github.com/ a57e3addfe0aa3857e12). Does anyone else see value for this in core? Is the code okay? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Yeah i have spent the last week trying to mount an app, is anyone else facing the same issue? On Oct 18, 1:13 pm, Joe Fiorini <j...@faithfulgeek.org> wrote:> When I mount an engine in config/routes.rb like so: > > mount Blog::Engine => "/blog" > > I''d like to be able to test that the routing is there. I added > assert_mounts to > ActionDispatch::Assertions::RoutingAssertions (https://gist.github.com/ > a57e3addfe0aa3857e12). Does anyone else see value for this in core? Is > the code okay?-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
I don''t think that you need to do such unit tests, without mounting an engine you will not be able to reach engine''s routes, so tests will fail anyway.> Yeah i have spent the last week trying to mount an appRemember that this is still an edge version and some things can (and probably will) change. I didn''t want to go with detailed guides before finishing work on new generator. Short story of creating mountable engine right now: # clone rails app and install dependencies git clone git://github.com/rails/rails.git cd rails bundle install # generate engine with routes and test dummy with engine already mounted bundle exec ./bin/rails plugin new /path/to/engine_name --dev -- mountable cd /path/to/engine_name bundle install # generate scaffold to test it ./script/rails generate scaffold post title:string content:text # run migrations cd test/dummy rake engine_name:install:migrations rake db:migrate ./script/rails s navigate to localhost:3000/engine_name/posts Testing is done using test/dummy. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On Oct 18, 7:13 pm, Joe Fiorini <j...@faithfulgeek.org> wrote:> ActionDispatch::Assertions::RoutingAssertions (https://gist.github.com/ > a57e3addfe0aa3857e12). Does anyone else see value for this in core? Is > the code okay?I personally would not use that. You''re just adding line to tests that ensures that you added line to routes. Instead of doing that I would rather add some higher level test that checks if you can reach engine at blog.root_path. But that''s just my opinion and I''m not in core, so maybe you will get more luck with the others ;-) -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Damn, google groups ate my post, so again ;) Joe Fiorini: I don''t like that kind of tests. You just add a line in tests that ensures that you added a line in routes. Better way to do that would be to check if engine can be properly rendered inside application. But I''m not in core and it''s only my biased opinion, so maybe you will get more luck with someone else ;) krishna: Remember that''s still edge version, it''s not in stable branch, it''s not released. While I know that things were moving slowly for engines a few last weeks, I''ll try to catch up in next few days. Short story for creating a mountable application right now (blog as an example): # close edge version of rails and install dependencies git clone https://github.com/rails/rails.git cd rails bundle install # create actual engine bundle exec ./bin/rails plugin new /path/to/blog --dev --mountable #install dependencies cd /path/to/blog bundle install # create simple scaffold ./script/rails generate scaffold post title:string content:text cd test/dummy rake blog:install:migrations rake db:migrate ./script/rails s navigate to localhost:3000/blog/posts -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
I agree with Piotr.You should never be testing that routes are there in your application, but rather that whatever''s on the end of that route is performing as it should.Let''s say that I have a /forums route that displays a list of forums, one of them being called "The Ghetto". In my test, I would assert that when I go to ForumsController#index that I see "The Ghetto" within "#forums h2".By doing this I''m testing at least three things:1) The route exists and that I can route to the controller2) The controller assigns information to a variable that the view can use3) The view renders that information correctly*(Correctly is subjective, design is an inexact science) -- Ryan Bigg On Wednesday, 17 November 2010 at 4:17 AM, Piotr Sarnacki wrote: On Oct 18, 7:13 pm, Joe Fiorini <j...@faithfulgeek.org> wrote: ActionDispatch::Assertions::RoutingAssertions (https://gist.github.com/ a57e3addfe0aa3857e12). Does anyone else see value for this in core? Is the code okay?I personally would not use that. You''re just adding line to tests thatensures that you added line to routes.Instead of doing that I would rather add some higher level test thatchecks if you can reach engine at blog.root_path. But that''s just myopinion and I''m not in core, so maybe you will get more luck with theothers ;-)-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.To post to this group, send email to rubyonrails-core@googlegroups.com.To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com.For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.