[rspec-users] request.params causing errors

David Chelimsky dchelimsky at gmail.com
Fri Apr 11 16:05:31 EDT 2008


On Apr 11, 2008, at 3:53 PM, Olivier Dupuis wrote:

> Sorry about that.  Here goes...
>
> Spec:
>
> describe "/search/index" do
>   it "should have option to login" do
>     render "/search/index"
>     response.should have_text(/Login/)
>   end
> end
>
> Code for index.rhtml
>
> <body>
>         <div id="container">
>                 <div id="main_footer" align="center">
>                         <%= render_component :controller =>  
> "components", :action => "footer", :params => { :lang => @language }  
> %>
>                 </div>
>         </div>
> </body>
>
> Code for footer.rhtml
>
> <% listOfParameters = "" %>
> <% request.params.each do |param| %>
>     <% if param[0].to_s != "lang" %>
>         <% listOfParameters = listOfParameters + "&" + param[0].to_s  
> + "=" + param[1].to_s %>
>     <% end %>
> <% end %>
>
> ...
>
> Now the error message:
>
> ActionView::TemplateError in '/search/index should have option to  
> login'
> undefined method 'params' for #<ActionController::TestRequest: 
> 0x46a044c>
> On line #7 of app/views/components/footer.rhtml
>
> 6: <% listOfParameters = "" %>
> 7: <% request.params.each do |param| %>

Try just params (not request.params) - does that work?

>
> 8:     <% if param[0].to_s != "lang" %>
> 9:         <% listOfParameters = listOfParameters + "&" +  
> param[0].to_s + "=" + param[1].to_s %>
> 10:     <% end %>
> 11: <% end %>
>
>
> Thanks again
>
> Olivier Dupuis
>
>
> On Fri, Apr 11, 2008 at 3:26 PM, David Chelimsky  
> <dchelimsky at gmail.com> wrote:
> Please post spec, code and error message.
>
> On Apr 11, 2008, at 3:21 PM, Olivier Dupuis wrote:
>
> > Hello,
> >
> > I have a rhtml file that goes through the request.params.  One of my
> > test generates that file, but rspec pops an error saying :
> >
> > undefined method 'params' for ...
> >
> > I'm not sure what to do with this, since request.params actually
> > works with rails.
> >
> > Any idea?
> >
> > Thank you
> >
> > 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080411/d9bd0c09/attachment-0001.html 


More information about the rspec-users mailing list