Hi Below is my functional test code def test_should_create_county assert_difference(''County.count'') do post :create, :county => {:name=>"myname",:description=>"mydesc",:region_id=>"3" } end assert_redirected_to county_path(assigns(:county)) end And error message i got is 29) Failure: test_should_create_county(CountiesControllerTest) [/test/functional/counties_controller_test.rb:16]: "County.count" didn''t change by 1. <3> expected but was <2>. Please help -- Karthik.k Mobile - +91-9894991640 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Can''t say what happens only based on this. Anyway please change above to def test_should_create_county County.destroy_all assert_difference(''County.count'') do post :create, :county => {:name=>"myname",:description=>"mydesc",:region_id=>"3" } end assert_redirected_to county_path(assigns(:county)) end Sijo -- Posted via http://www.ruby-forum.com/.
Hi Sijo Thank you but Still i find the same error Can you please say why this happens Any idea -- Karthik.k Mobile - +91-9894991640 On Tue, Aug 4, 2009 at 12:22 PM, Sijo Kg <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>wrote:> > Hi > Can''t say what happens only based on this. Anyway please change > above to > > def test_should_create_county > County.destroy_all > assert_difference(''County.count'') do > post :create, :county => > {:name=>"myname",:description=>"mydesc",:region_id=>"3" } > end > assert_redirected_to county_path(assigns(:county)) > end > > Sijo > -- > 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 -~----------~----~----~----~------~----~------~--~---
Hi Check for any unsatisfied validations Sijo -- Posted via http://www.ruby-forum.com/.
On Tue, Aug 4, 2009 at 1:36 PM, Sijo Kg <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>wrote:> > Hi > Check for any unsatisfied validations > > Sijo > -- > Posted via http://www.ruby-forum.com/. > > > >hi Sijo Ya i saw but no unsatisfied validations is there, i have one doubt in each controller, there is authentication checked, does that affect this functional testing any idea plz help -- Karthik.k Mobile - +91-9894991640 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Tue, Aug 4, 2009 at 1:53 PM, karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Tue, Aug 4, 2009 at 1:36 PM, Sijo Kg <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>wrote: > >> >> Hi >> Check for any unsatisfied validations >> >> Sijo >> -- >> Posted via http://www.ruby-forum.com/. >> >> >> >> > hi Sijo > > Ya i saw but no unsatisfied validations is there, i have one doubt > in each controller, there is authentication checked, does that affect this > functional testing > > any idea > > plz help >Hi Sijo I think you are tired helping me When i run scaffolding and run functional testing also it provides error message Is there any initial setup for functional testing I am not able to run the basic functional testing that scaffolding generates karthik.k --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Just to know which version of rails r u using Please check this http://guides.rubyonrails.org/testing.html Sijo -- Posted via http://www.ruby-forum.com/.
On Tue, Aug 4, 2009 at 4:05 PM, Sijo Kg <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>wrote:> > Just to know which version of rails r u using Please check this > > http://guides.rubyonrails.org/testing.html > > > Sijo >Hi Sijo I use 2.3.2 I use Aptana IDE Ya i saw the link when i started but i am not getting what i need from that link -- Karthik.k Mobile - +91-9894991640> -- > 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 -~----------~----~----~----~------~----~------~--~---
On Aug 4, 9:23 am, karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, Aug 4, 2009 at 1:36 PM, Sijo Kg <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>wrote: > > Ya i saw but no unsatisfied validations is there, i have one doubt > in each controller, there is authentication checked, does that affect this > functional testingIf your controller normally requires users to be logged in then you will need to make it appear that the test requests are coming from a logged in user. Fred> > any idea > > plz help > > -- > Karthik.k > Mobile - +91-9894991640
Yes as Fred said you need that and suppose if you are using a session varible person_id it can be done like for example in test_helper just write a def like def login_as(person) @request.session[:person_id] = person ? person.id : nil end And from your test call this by passing administrator object as variable Sijo -- Posted via http://www.ruby-forum.com/.
On Tue, Aug 4, 2009 at 4:36 PM, Sijo Kg <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>wrote:> > Yes as Fred said you need that and suppose if you are using a session > varible person_id it can be done like for example in test_helper just > write a def like > > def login_as(person) > @request.session[:person_id] = person ? person.id : nil > end > > And from your test call this by passing administrator object as > variable > > > > SijoThank you sijo I will do that and let you know -- Karthik.k Mobile - +91-9894991640> -- > 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 -~----------~----~----~----~------~----~------~--~---
On Tue, Aug 4, 2009 at 4:23 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On Aug 4, 9:23 am, karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On Tue, Aug 4, 2009 at 1:36 PM, Sijo Kg < > rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>wrote: > > > > Ya i saw but no unsatisfied validations is there, i have one doubt > > in each controller, there is authentication checked, does that affect > this > > functional testing > > If your controller normally requires users to be logged in then you > will need to make it appear that the test requests are coming from a > logged in user. > > Fredthank you Fred I will do that and let you know -- Karthik.k Mobile - +91-9894991640> > > > > any idea > > > > plz help > > > > -- > > Karthik.k > > Mobile - +91-9894991640 > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Sijo Kg wrote:> Hi > Can''t say what happens only based on this. Anyway please change > above to > > def test_should_create_county > County.destroy_allThat destroy should not matter. (And assert_latest is much more accurate & useful than assert_difference here.)> assert_difference(''County.count'') do > post :create, :county => > {:name=>"myname",:description=>"mydesc",:region_id=>"3" } > end > assert_redirected_to county_path(assigns(:county)) > endMost likely you fail validation. If your error flashes to the page, you can put assert_match /something/, flash[:warning], or the equivalent, above the assert_redirect. Otherwise, change your save to save! and see if you get a crash message. -- Phlip