[rspec-users] response is null when using should_render_rjs

Michael Johnston lastobelus at mac.com
Thu Nov 30 03:48:04 EST 2006


I'm trying to use rspec to test a controller that has ajax.

I have the following action:

   def change_ad_type_form
     render :update do |page|
       page.replace_html 'ad_sub_form', :partial => 'text'
     end
   end

and the following spec:

   specify "should return Text subform on AJAX request to  
change_ad_type_form" do
     controller.should_render_rjs :page,  
'ad_sub_form', :replace_html, 'stuff'
     get 'change_ad_type_form'
   end

which result is the following:

1)
NoMethodError in 'When creating a new ad, the ad_controller should  
return Text subform on AJAX request to change_ad_type_form'
nil does not respond to `rjs' or `has_rjs?'
/Users/lasto/clients/ibc/project_n/vendor/plugins/rspec/lib/spec/ 
rails/render_matcher.rb:61:in `should_render_rjs'
/Users/lasto/clients/ibc/project_n/vendor/plugins/rspec/lib/spec/ 
rails/context/controller.rb:63:in `should_render_rjs'
./spec/controllers/ad_controller_spec.rb:75

(because response is null when it gets to render_matcher)

What am I doing wrong?


Cheers,
Michael


More information about the rspec-users mailing list