Danny Sofer
2008-Jun-15 09:33 UTC
[rspec-users] RSpec story failing because of routing error on "/"
Greetings! Here''s the problem. When running tests on the restful_authentication plugin, I am getting a routing error on "/". Which I don''t really understand, because the route "/" certainly does exist as I can confirm when I run ./script/server and point my browser at http://localhost:3000/ Here is an example of the error I am getting when I run "ruby stories/ rest_auth_stories.rb": Scenario: Anonymous user can get a login form. Given an anonymous user (FAILED) When she goes to /login Then she should be at the new sessions page And the page should look AWESOME (SKIPPED) And she should see a <form> containing a textfield: Login, password: Password, and submit: ''Log in'' <snip/> FAILURES: 1) Creating an account (Anonymous user can start creating an account) FAILED ActionController::RoutingError: No route matches "/" with {:method=>:get} ./stories/steps/user_steps.rb:104:in `log_out!'' ./stories/steps/user_steps.rb:12:in `an anonymous user'' stories/rest_auth_stories.rb:17 <snip/> I am running: Rails: 2.1.0 RSpec-1.1.4 And this is a completely fresh install with no code added by me. Here are the steps to replicate (from my app root): git clone git://github.com/rails/rails.git vendor/rails git clone git://github.com/dchelimsky/rspec.git vendor/plugins/rspec git clone git://github.com/dchelimsky/rspec-rails.git vendor/plugins/ rspec-rails git clone git://github.com/technoweenie/restful-authentication.git vendor/plugins/restful-authentication ./script/generate rspec ./script/generate authenticated user sessions mate app/controllers (and added " include AuthenticatedSystem" to the application controller) rake db:migrate rake db:test:prepare ruby stories/rest_auth_stories.rb Many thanks for your kind attention, danny sofer -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2458 bytes Desc: not available URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080615/6a3c0eab/attachment.bin>
David Chelimsky
2008-Jun-15 13:09 UTC
[rspec-users] RSpec story failing because of routing error on "/"
On Jun 15, 2008, at 4:33 AM, Danny Sofer wrote:> Greetings! > > Here''s the problem. > > When running tests on the restful_authentication plugin, I am > getting a routing error on "/". > > Which I don''t really understand, because the route "/" certainly > does exist as I can confirm when I run ./script/server and point my > browser at http://localhost:3000/Actually, that route does NOT exist. You''re seeing something because there is an index.html file in public, not because Rails routing is getting you there. Add an explicit root mapping to the appropriate controller and you''ll get past this. Looks like there are more problems ahead, but they seem to be in restful_authentication. Cheers, David> Here is an example of the error I am getting when I run "ruby > stories/rest_auth_stories.rb": > > Scenario: Anonymous user can get a login form. > > Given an anonymous user (FAILED) > > When she goes to /login > > Then she should be at the new sessions page > And the page should look AWESOME (SKIPPED) > And she should see a <form> containing a textfield: Login, > password: Password, and submit: ''Log in'' > > <snip/> > > FAILURES: > 1) Creating an account (Anonymous user can start creating an > account) FAILED > ActionController::RoutingError: No route matches "/" with > {:method=>:get} > ./stories/steps/user_steps.rb:104:in `log_out!'' > ./stories/steps/user_steps.rb:12:in `an anonymous user'' > stories/rest_auth_stories.rb:17 > > <snip/> > > I am running: > > Rails: 2.1.0 > RSpec-1.1.4 > > And this is a completely fresh install with no code added by me. > > Here are the steps to replicate (from my app root): > > git clone git://github.com/rails/rails.git vendor/rails > git clone git://github.com/dchelimsky/rspec.git vendor/plugins/rspec > git clone git://github.com/dchelimsky/rspec-rails.git vendor/plugins/ > rspec-rails > git clone git://github.com/technoweenie/restful-authentication.git > vendor/plugins/restful-authentication > > ./script/generate rspec > ./script/generate authenticated user sessions > > mate app/controllers (and added " include AuthenticatedSystem" to > the application controller) > > rake db:migrate > rake db:test:prepare > > ruby stories/rest_auth_stories.rb > > > Many thanks for your kind attention, > > > danny sofer > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
Danny Sofer
2008-Jun-15 21:33 UTC
[rspec-users] RSpec story failing because of routing error on "/"
On 15 Jun 2008, at 14:09, David Chelimsky wrote:> On Jun 15, 2008, at 4:33 AM, Danny Sofer wrote: > >> When running tests on the restful_authentication plugin, I am >> getting a routing error on "/". >> >> Which I don''t really understand, because the route "/" certainly >> does exist as I can confirm when I run ./script/server and point my >> browser at http://localhost:3000/ > > Actually, that route does NOT exist. You''re seeing something because > there is an index.html file in public, not because Rails routing is > getting you there. > > Add an explicit root mapping to the appropriate controller and > you''ll get past this. Looks like there are more problems ahead, but > they seem to be in restful_authentication. > > Cheers, > DavidOh, a bit obvious! Thank you so much. For the record, it is possible to get the Restful Authentication stories running with a few extra steps. After installing all the various plugins as outlined in my previous missive, do the following: 1. Add a "/" route to config.routes.rb: (as pointed out by David) map.login ''/'', :controller => ''sessions'', :action => ''new'' 2. Copy the line "include AuthenticatedSystem" into class ApplicationController in app/controllers/application.rb 3. Add app/views/layouts/application.html.erb with something like the following: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html> <head> <title>Restful auth</title> </head> <body> <div class="notice"><%= flash[:notice] %></div> <div class="error"><%= flash[:error] %></div> <%= yield :layout %> </body> </html> 4. In /stories/sessions/users/sessions.story there is a scenario which assumes that "fixtures have been run sometime". Well they haven''t, so: "And her session store should have user_id: 1" (and not 4) on lines 56 and 110. Then run: ruby stories/rest_auth_stories.rb "16 scenarios: 16 succeeded, 0 failed, 0 pending" Hooray!> git clone git://github.com/rails/rails.git vendor/rails > git clone git://github.com/dchelimsky/rspec.git vendor/plugins/rspec > git clone git://github.com/dchelimsky/rspec-rails.git vendor/plugins/ > rspec-rails > git clone git://github.com/technoweenie/restful-authentication.git > vendor/plugins/restful-authentication > > ./script/generate rspec > ./script/generate authenticated user sessions > > mate app/controllers (and added " include AuthenticatedSystem" to > the application controller) > > rake db:migrate > rake db:test:prepare > >-------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2458 bytes Desc: not available URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080615/f3419610/attachment.bin>