Given the following helper method, how would I correctly check this with rspec ?
def datatable(rows = [], headers = []) render 'shared/datatable', { :rows => rows, :headers => headers } end def table(headers = [], data = []) render 'shared/table', headers: headers, data: data end
I tried the following but get an error: can't convert nil into String
describe 'datatable' do it 'renders the datatable partial' do rows = [] headers = [] helper.should_receive('render').with(any_args) datatable(rows, headers) end end
Rspec output
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 <top (required)>'
./app// helpers/application_helper.rb: 26
render 'shared/datatable', { :rows => rows, :headers => headers }
view / general / _datatable.html.haml
= table headers, rows
view / general / _table.html.haml
%table.table.dataTable %thead %tr - headers.each do |header| %th= header %tbody - data.each do |columns| %tr - columns.each do |column| %td= column
source share