I'm writing rspec tests for my controller and trying to test the rendering of a partial, when the action is triggered by an AJAX requisition.
In my controller code, I have:
def new
...
respond_to do |format|
format.html { render action: "new" }
format.js { }
end
end
I have the files new.html.erb and new.js.erb placed the correct view directory.
And my rspec test is the following:
it "should render the new partial" do
get :new, :format => 'js'
response.should render_template(:partial => 'new')
end
When executing this rspec test I get the following error:
Failure/Error: response.should render_template(:partial => 'new')
expecting partial <"new"> but action rendered <[]>
Can somebody figure why I am getting this error? What am I doing wrong?
Thank you
get :new, :format => 'js') and this codeformat.js { }in controller works. and I think it should NOT render any partial.new.js.erbcontents?response.body{ }, so it becomesformat.jsonly