title: Test that rails helper renders a partial
body: <p>Given the following helper method, how would I properly test this using <code>rspec</code>?</p>
  
  <pre><code>  def datatable(rows = [], headers = [])
      render 'shared/datatable', { :rows =&gt; rows, :headers =&gt; headers }
    end
  
    def table(headers = [], data = [])
      render 'shared/table', headers: headers, data: data
    end
  </code></pre>
  
  <p>I've tried the following but I get the error: <code>can't convert nil into String</code></p>
  
  <pre><code>describe 'datatable' do
    it 'renders the datatable partial' do
      rows = []
      headers = []
      helper.should_receive('render').with(any_args)
      datatable(rows, headers)
    end
  end
  </code></pre>
  
  <p><strong>Rspec Output</strong></p>
  
  <pre><code>Failures:
  
    1) ApplicationHelper datatable renders the datatable partial
       Failure/Error: datatable(rows, headers)
       TypeError:
         can't convert nil into String
       # ./app/helpers/application_helper.rb:26:in `datatable'
       # ./spec/helpers/application_helper_spec.rb:45:in `block (3 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p><strong>./app/helpers/application_helper.rb:26</strong></p>
  
  <pre><code>render 'shared/datatable', { :rows =&gt; rows, :headers =&gt; headers }
  </code></pre>
  
  <p><strong>views/shared/_datatable.html.haml</strong></p>
  
  <pre><code>= table headers, rows
  </code></pre>
  
  <p><strong>views/shared/_table.html.haml</strong></p>
  
  <pre><code>%table.table.dataTable
    %thead
      %tr
        - headers.each do |header|
          %th= header
    %tbody
      - data.each do |columns|
        %tr
          - columns.each do |column|
            %td= column
  </code></pre>