Hi, In my RESTful implementation, :new shows a form for @link . When a user clicks on Create, the value of @link is posted to :create through params. How do I test the value of params and that :create actually uses these value to create a new link. Right now I test :create by by using a link fixture but I want to actually use the value of params passed in through :new. I suspect that an integration test is needed but how can I do this? Thanks. Vincent. -- 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.
What''s your test suite of choice? Using plain old TestUnit, try something like this: def test_link_creates_correctly post :create, :link => {:name => ''Contact Us'', :href => ''/ contact'', :title => ''Contact Us''} assert Link.find(:first, :conditions => {:name => ''Contact Us'', :href => ''/contact'', :title => ''Contact Us''}) end This will test that the record was created as you wish. Honestly though, I don''t test for this, and I''m more paranoid than most. If you''re passing params[:link] to your Link.new method in the create action, that''s good enough. Since I stub out most database interaction with Mocha, I actually just test that Link.new was *called* with the right parameters. If you want to go nuts on controller tests, I have a pretty detailed article about it with more to come: http://kconrails.com/2009/12/30/restful-tests-with-shoulda/ And if you have any questions, contact me through my blog or twitter (@kconrails) and I''ll be glad to help! Jaime On Jan 16, 8:45 pm, Vincent P <ease...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > In my RESTful implementation, :new shows a form for @link . When a > user clicks on Create, the value of @link is posted to :create through > params. How do I test the value of params and that :create actually > uses these value to create a new link. > > Right now I test :create by by using a link fixture but I want to > actually use the value of params passed in through :new. I suspect > that an integration test is needed but how can I do this? > > Thanks. > > Vincent.-- 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.
Learn by Doing wrote:> Hi, > > In my RESTful implementation, :new shows a form for @link . When a > user clicks on Create, the value of @link is posted to :create through > params. How do I test the value of params and that :create actually > uses these value to create a new link. > > Right now I test :create by by using a link fixture but I want to > actually use the value of params passed in through :new. I suspect > that an integration test is needed but how can I do this?Use Cucumber. It makes this kind of thing pretty easy.> > Thanks. > > Vincent.Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. --00032555412acad625047d5451cc Content-Type: text/plain; charset=ISO-8859-1 -- 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. --00032555412acad625047d5451cc--
Thanks all. Cucumber sounds very promising. I will pick up a book on BDD. On Jan 16, 8:03 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Learn by Doing wrote: > > Hi, > > > In my RESTful implementation, :new shows a form for @link . When a > > user clicks on Create, the value of @link is posted to :create through > > params. How do I test the value of params and that :create actually > > uses these value to create a new link. > > > Right now I test :create by by using a link fixture but I want to > > actually use the value of params passed in through :new. I suspect > > that an integration test is needed but how can I do this? > > Use Cucumber. It makes this kind of thing pretty easy. > > > > > Thanks. > > > Vincent. > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > Posted viahttp://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.