Olivier Dupuis
2007-Nov-30 02:29 UTC
[rspec-users] Rendering a view and passing a variable
Hello all, I have a view which display html based on the value of a variable. Here''s the code : <% if @language == ''e'' %> <%= link_to "Français", :action => :index, :id => "f" %> <% end %> In my test, I''m trying to set the value of the variable first, but that just doesn''t seem to work : it "should display in english when @language is equal to ''E''" do @language = "e" render "/search/index" response.should have_tag("a[href=?]", "/search/index/f") end I get the error message saying that no tag was found. Any help would be appreciated Thank you in advance Olivier Dupuis -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071129/72a905bc/attachment.html
David Chelimsky
2007-Nov-30 02:29 UTC
[rspec-users] Rendering a view and passing a variable
On Nov 29, 2007 8:29 PM, Olivier Dupuis <odupuis at uottawa.ca> wrote:> > > > > Hello all, > > I have a view which display html based on the value of a variable. Here''s > the code : > > <% if @language == ''e'' %> > <%= link_to "Français", :action => :index, :id => "f" %> > <% end %> > > In my test, I''m trying to set the value of the variable first, but that > just doesn''t seem to work : > > it "should display in english when @language is equal to ''E''" do > @language = "e" > render "/search/index" > response.should have_tag("a[href=?]", "/search/index/f") > end > > I get the error message saying that no tag was found. > > Any help would be appreciatedhttp://rspec.rubyforge.org/documentation/rails/writing/views.html assigns[:language] = "e" Cheers, David> > Thank you in advance > > Olivier Dupuis > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
don''t you have to do ... assigns[:language] = @language On 30/11/2007, at 3:29 PM, Olivier Dupuis wrote:> > Hello all, > > I have a view which display html based on the value of a variable. > Here''s the code : > > <% if @language == ''e'' %> > <%= link_to "Français", :action => :index, :id => "f" %> > <% end %> > > In my test, I''m trying to set the value of the variable first, but > that just doesn''t seem to work : > > it "should display in english when @language is equal to ''E''" do > @language = "e" > render "/search/index" > response.should have_tag("a[href=?]", "/search/index/f") > end > > I get the error message saying that no tag was found. > > Any help would be appreciated > > Thank you in advance > > Olivier Dupuis > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-usersShane Mingins ELC Technologies (TM) 1921 State Street Santa Barbara, CA 93101 Phone: +64 4 568 6684 Mobile: +64 21 435 586 Email: smingins at elctech.com AIM: ShaneMingins Skype: shane.mingins (866) 863-7365 Tel - Santa Barbara Office (866) 893-1902 Fax - Santa Barbara Office +44 020 7504 1346 Tel - London Office +44 020 7504 1347 Fax - London Office http://www.elctech.com -------------------------------------------------------------------- Privacy and Confidentiality Notice: The information contained in this electronic mail message is intended for the named recipient(s) only. It may contain privileged and confidential information. If you are not an intended recipient, you must not copy, forward, distribute or take any action in reliance on it. If you have received this electronic mail message in error, please notify the sender immediately. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071130/02091455/attachment-0001.html
Olivier Dupuis
2007-Nov-30 02:44 UTC
[rspec-users] Rendering a view and passing a variable
Thanks again David! Sorry for the easy question. I should have looked more carefully at the documentation. Olivier -----Original Message----- From: rspec-users-bounces at rubyforge.org on behalf of David Chelimsky Sent: Thu 11/29/2007 9:29 PM To: rspec-users Subject: Re: [rspec-users] Rendering a view and passing a variable On Nov 29, 2007 8:29 PM, Olivier Dupuis <odupuis at uottawa.ca> wrote:> > > > > Hello all, > > I have a view which display html based on the value of a variable. Here''s > the code : > > <% if @language == ''e'' %> > <%= link_to "Français", :action => :index, :id => "f" %> > <% end %> > > In my test, I''m trying to set the value of the variable first, but that > just doesn''t seem to work : > > it "should display in english when @language is equal to ''E''" do > @language = "e" > render "/search/index" > response.should have_tag("a[href=?]", "/search/index/f") > end > > I get the error message saying that no tag was found. > > Any help would be appreciatedhttp://rspec.rubyforge.org/documentation/rails/writing/views.html assigns[:language] = "e" Cheers, David> > Thank you in advance > > Olivier Dupuis > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >_______________________________________________ rspec-users mailing list rspec-users at rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/ms-tnef Size: 3414 bytes Desc: not available Url : http://rubyforge.org/pipermail/rspec-users/attachments/20071129/7e3cc1f5/attachment.bin
David Chelimsky
2007-Nov-30 02:46 UTC
[rspec-users] Rendering a view and passing a variable
On Nov 29, 2007 8:44 PM, Olivier Dupuis <odupuis at uottawa.ca> wrote:> Thanks again David! > > Sorry for the easy question. I should have looked more carefully at the documentation.Please, no apologies. The docs aren''t perfect, so while it''s good to know they''re there, you should always feel free to ask. Cheers, David> > Olivier > > > > -----Original Message----- > From: rspec-users-bounces at rubyforge.org on behalf of David Chelimsky > Sent: Thu 11/29/2007 9:29 PM > To: rspec-users > Subject: Re: [rspec-users] Rendering a view and passing a variable > > On Nov 29, 2007 8:29 PM, Olivier Dupuis <odupuis at uottawa.ca> wrote: > > > > > > > > > > Hello all, > > > > I have a view which display html based on the value of a variable. Here''s > > the code : > > > > <% if @language == ''e'' %> > > <%= link_to "Français", :action => :index, :id => "f" %> > > <% end %> > > > > In my test, I''m trying to set the value of the variable first, but that > > just doesn''t seem to work : > > > > it "should display in english when @language is equal to ''E''" do > > @language = "e" > > render "/search/index" > > response.should have_tag("a[href=?]", "/search/index/f") > > end > > > > I get the error message saying that no tag was found. > > > > Any help would be appreciated > > http://rspec.rubyforge.org/documentation/rails/writing/views.html > > assigns[:language] = "e" > > Cheers, > David > > > > > Thank you in advance > > > > Olivier Dupuis > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >