Hi all,
I have a spec for my controller (and its routing) that looks like this:
describe "named routes" do
before do
# mini-hack: need a GET before the named routes are loaded
get :index
end
it "admin_venue_merges_path.should ==
''/admin/venue_merges''" do
admin_venue_merges_path.should == "/admin/venue_merges"
end
end
Trouble is, I don''t actually need an index action on this particular
controller - it''s just there so that I can spin up whatever the code is
within ActionPack that loads those named route methods.
What I''d prefer to do is directly call ActionController or whatever and
tell it to load the named routes.
I''m fairly new to ruby and find the source code to ActionPack pretty
overwhelming.
Can anyone more au fait with the rails source tell me how I might
achieve this?
--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
I recommend generating an rspec_scaffold. It gives some nice examples for
model, controller and view specs.
$ script/generate rspec_scaffold Person name:string age:integer
gives this for verifying routing:
describe PeopleController do
describe "route generation" do
it "should map #index" do
route_for(:controller => "people", :action =>
"index").should ="/people"
end
...
end
...
end
Regards,
Craig
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Craig Demyanovich wrote:> I recommend generating an rspec_scaffold. > gives this for verifying routing: > > describe PeopleController do > describe "route generation" do > it "should map #index" do > route_for(:controller => "people", :action => "index").should => "/people" > end > ... > end > ... > endOkay sure, but if I want to test the *named route*, for example if I want to put a route into a namespace, how do I write a test for that? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---