Hi all, in a test I''m doing I''m looking for a div of class errorExplanation to know if an update passed validation, but even if the rendered html has it, as you can see below, the assert_tag fails. What am I doing wrong? expected tag, but no tag found matching {:attributes=>{:class=>"errorExplanation"}, :tag=>"div"} in: "HWait(''0'');HWait(''00'');\nif($(''flashesint'') !undefined){Effect.Fade(''flashesint'',{duration: 0.7});Effect.BlindUp(''flashesint'', {duration: 0.7});}\nsetTimeout(function() {\n;\n}, 800);\nElement.update(\"mac_address_number_1\", \"\\n\\074div class=\\\"errorExplanation\\\" id=\\\"errorExplanation\\\"\\076\\074h2\\0761 error prohibited this mac address from being saved\\074/h2\\076\\074p\\076There were problems with the following fields:\\074/p\\076\\074ul\\076\\074li\\076Mac address is not a valid MAC Address\\074/li\\076\\074/ul\\076\\074/div\\076 \\n\\074form.... Thank you, Emanuele. -- 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 -~----------~----~----~----~------~----~------~--~---
Really noone has a clue? -- 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 29 Nov 2007, at 15:43, Emanuele Ricci wrote:> > Hi all, > in a test I''m doing I''m looking for a div of class errorExplanation to > know if an update passed validation, but even if the rendered html has > it, as you can see below, the assert_tag fails. What am I doing wrong? >assert_tag is quite literally looking for a div tag of that class, which your output does not contain. It does contain javascript for inserting such a tag, but assert_tag doesn''t understand that. You probably want to use assert_select_rjs (I also find the arts plugin useful for this sort of stuff) Fred> > expected tag, but no tag found matching > {:attributes=>{:class=>"errorExplanation"}, :tag=>"div"} in: > "HWait(''0'');HWait(''00'');\nif($(''flashesint'') !> undefined){Effect.Fade(''flashesint'',{duration: > 0.7});Effect.BlindUp(''flashesint'', {duration: > 0.7});}\nsetTimeout(function() {\n;\n}, > 800);\nElement.update(\"mac_address_number_1\", \"\\n\\074div > class=\\\"errorExplanation\\\" > id=\\\"errorExplanation\\\"\\076\\074h2\\0761 error prohibited this > mac > address from being saved\\074/h2\\076\\074p\\076There were problems > with > the following fields:\\074/p\\076\\074ul\\076\\074li\\076Mac address > is > not a valid MAC Address\\074/li\\076\\074/ul\\076\\074/div\\076 > \\n\\074form.... > > > Thank you, > Emanuele. > -- > 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 29 Nov 2007, at 15:43, Emanuele Ricci wrote: > >> >> Hi all, >> in a test I''m doing I''m looking for a div of class errorExplanation to >> know if an update passed validation, but even if the rendered html has >> it, as you can see below, the assert_tag fails. What am I doing wrong? >> > assert_tag is quite literally looking for a div tag of that class, > which your output does not contain. It does contain javascript for > inserting such a tag, but assert_tag doesn''t understand that. > You probably want to use assert_select_rjs (I also find the arts > plugin useful for this sort of stuff) > > FredThank you very much for your answer, I'' ll look into assert_select_rjs and arts, till now I patched it with a custom assertion that works for me: def assert_validation_success assert got_validation_error.nil?, "Not valid!" end def got_validation_error @response.body.inspect.match(/.*errorExplanation.*/) end Emanuele. -- 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 -~----------~----~----~----~------~----~------~--~---