[rspec-users] questions rspec on rails

Jonathan Linowes jonathan at parkerhill.com
Tue May 29 04:54:52 EDT 2007


Hi, rather than flooding this list with separate emails, I've been  
queueing up questions using rspec with rails. (an irc channel would  
be nice too :) Here ya go...


- Is there a way to test named routes?


- Could I get an example how to test an ajax request  
(link_to_remote)? would that go in view? and/or in controller spec?


- Can you assert which layout template is rendered in a controller spec?


- How to test application_helper.rb helpers?
(creating a file spec/helpers/application_helper_spec.rb like other  
helper_spec files gives an error
no such file to load -- ./spec/helpers/../application_helper (LoadError)


- How to write a test (uh, i mean spec) for helpers that take blocks?
for example:
   def link_block_to_remote( options = {}, html_options = {}, &block)
     concat(link_to_remote(capture(&block), options, html_options),  
block.binding)
   end


- How can i test ActionMailer? eg ensure it renders the correct  
template.
- Is there an equivalent to script/generate mailer ,eg rspec_mailer  
that generates specs? and/or do you have examples of mailer specs?


- Do you have recommendations for using authentication? should i load  
a users.yml fixture or setup users some other way? (my controllers  
and views may check for current_user, logged_in?, etc) (I use  
restful_authentication)


- this may not be rspec at all, I'm calling assert_difference  
(defined in /lib/authenticated_test_helper.rb) with 3 args but get an  
error that it expects 2. Is there another version of this method  
somewhere? I cant find it. If i rename the one i know and call that  
(eg assert_difference3) its ok.


- do any of you also use topfunky_power_tools (ref peepcode testing  
video) But I dont know how to get my specs to find the topfunky  
test_helper.rb file. (btw, that file also has a assert_difference but  
it also takes 3 args... )


- peepcode also suggests vic_tests for integration testing. Have you  
used that, what do you think?


- Running autotest, when a spec errors, autotest sometimes tries re- 
running the test 2, 3, sometimes many more times repeatedly although  
I dont touche the file again. Is this a known bug?


That's it for now :) thanks
linoj




More information about the rspec-users mailing list