Hello, This is the test code. Over here i am trying to test the partial, is it render or not? I tried to test it with assert_tag, but its giving me an error and the whole dump of th partial. I have never tested partial. So if any body has test partial, please help me with this def test_update_cloud get :update_cloud assert_response(:success) assert_tag :tag => ''span'',attributes => { :id => "notification" } end -------------------------------------------- This is the controller code I went to test. def update_cloud cloud render :partial => "/shared/cloud" end ------------------------------------------------------------------- This is the small piece of parial code called ''cloud'' it''s in shared directory <SCRIPT language="javascript"> 98 var total = <%= @num_size_one+@num_size_two+@num_size_three +@num_size_four+@num_size_five %> 99 </script> 100 Highlight level? <%= select_tag ''num_gray[]'', 101 options_for_select({ ''least (''+@num_size_one.to_s+'')'' => 1, ''less (''+@num_size_two.to_s+'')'' => 2, ''average (''+@num_size_three.to_s +'')'' => 3, ''more (''+@num_size_four.to_s+'')'' => 4, ''most (''+@num_size_five.to_s+'')''=> 5}.sort{|a,b| a[1]<=>b[1]}, @num_gray), :onchange => ''changeColor(this.options[this.selectedIndex].value)'' %> 102 <span id="notification"></span><br /> 103 104 <%= @link2 %> ---------------------------------- This is the cloud method, not really relevent here. def cloud # tag_id is in both triples and events tables. which one? # ajax feature to choose how many tags are going to be gray @num_gray = params[:num_gray] ? params[:num_gray].to_i : 1 logger.debug '' num_gray = %s '' % @num_gray @total = 0 #number of all tag_id @size_tag = Hash.new @distinct_triples = Triple.find_by_sql("select distinct tag_id from triples") logger.debug '' distinct_triples = %s '' % @distinct_triples @distinct_triples.each do |t| if(!t.tag.nil? && !t.tag.name.empty?) then @size_tag[t.tag_id] = Triple.find(:all, :condition [ "tag_i= ?",t.tag_id ]).size @total += @size_tag[t.tag_id] end Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
One of these must work, def test_update_cloud get :update_cloud assert_response(:success) assert_tag :tag => ''span'', :attributes => { :id => "notification" } end OR def test_update_cloud get :update_cloud assert_response(:success) assert_tag :tag => ''span'', :attributes => { :id => /notification/ } end On Nov 7, 10:26 am, sam <ladak....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > This is the test code. Over here i am trying to test the partial, is > it render or not? > > I tried to test it with assert_tag, but its giving me an error and > the whole dump of th partial. > I have never tested partial. So if any body has test partial, please > help me with this > > def test_update_cloud > get :update_cloud > assert_response(:success) > assert_tag :tag => ''span'',attributes => { :id => "notification" } > end > > -------------------------------------------- > This is the controller code I went to test. > > def update_cloud > cloud > render :partial => "/shared/cloud" > end > > ------------------------------------------------------------------- > This is the small piece of parial code called ''cloud'' it''s in shared > directory > > <SCRIPT language="javascript"> > 98 var total = <%= @num_size_one+@num_size_two+@num_size_three > +@num_size_four+@num_size_five %> > 99 </script> > 100 Highlight level? <%= select_tag ''num_gray[]'', > 101 options_for_select({ ''least (''+@num_size_one.to_s+'')'' => 1, > ''less (''+@num_size_two.to_s+'')'' => 2, ''average (''+@num_size_three.to_s > +'')'' => 3, ''more (''+@num_size_four.to_s+'')'' => 4, ''most > (''+@num_size_five.to_s+'')''=> 5}.sort{|a,b| a[1]<=>b[1]}, > @num_gray), :onchange => > ''changeColor(this.options[this.selectedIndex].value)'' %> > 102 <span id="notification"></span><br /> > 103 > 104 <%= @link2 %> > > ---------------------------------- > > This is the cloud method, not really relevent here. > > def cloud > # tag_id is in both triples and events tables. which one? > # ajax feature to choose how many tags are going to be gray > @num_gray = params[:num_gray] ? params[:num_gray].to_i : 1 > logger.debug '' num_gray = %s '' % @num_gray > > @total = 0 #number of all tag_id > @size_tag = Hash.new > @distinct_triples = Triple.find_by_sql("select distinct tag_id > from triples") > logger.debug '' distinct_triples = %s '' % @distinct_triples > > @distinct_triples.each do |t| > if(!t.tag.nil? && !t.tag.name.empty?) then > @size_tag[t.tag_id] = Triple.find(:all, :condition > [ "tag_i= ?",t.tag_id ]).size > @total += @size_tag[t.tag_id] > end > > Thanks--~--~---------~--~----~------------~-------~--~----~ 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 Nov 7, 2007 12:26 AM, sam <ladak.sam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hello, > > This is the test code. Over here i am trying to test the partial, is > it render or not? > > I tried to test it with assert_tag, but its giving me an error and > the whole dump of th partial. > I have never tested partial. So if any body has test partial, please > help me with this > > > > def test_update_cloud > get :update_cloud > assert_response(:success) > assert_tag :tag => ''span'',attributes => { :id => "notification" } > endThe colon is missing on :attributes, but I see you have it correct in your followup message. Don''t retype code; cut and paste. The assert_tag call is fine, but assert_select is the new sexy way to do this. In any event, we can''t help unless you post the specific error message and identify the specific line that is raising the message. Your test looks OK as written. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---