Unable to test render function for helper methods in rspec

I am using Rails 2.3.4 and Rspec 1.2.0. I am trying to check an assistant who is trying to display a page or partial, I get an exception like

undefined `render 'method for

Suppose my helper method

def some_helper render(:partial => "some/partial", :locals => {:some => some} end 

and calling it a specification

 it "should render the partial" do some_helper.should render_template("some/partial") end 

Any suggestion would be helpful

+6
source share
2 answers

What about:

 it "should render the partial" do helper.should_receive("render").with("some/partial") some_helper end 

UPDATE

When you use the new wait syntax, I would do

 it "renders the partial" do allow(helper).to receive(:render) some_helper expect(helper).to have_received(:render).with("some/partial") end 
+8
source

Eric C.'s solution above does not work for me. If someone finds the same, here is my working test code:

 it 'renders the template' do allow(helper).to receive(:render).and_call_original helper.helper_method(arg) expect(helper).to have_received(:render).with(partial: 'my/partial') end 
0
source

Source: https://habr.com/ru/post/897743/


All Articles