require 'spec_helper'
include ActionView::Helpers
include ActionView::Context
include Easytable::ActionView
describe Easytable::ActionView do
describe 'Empty table' do
let(:header) { [] }
let(:columns) { [] }
subject { render_table_for(table_header: header, columns: columns) }
it 'should render table tag' do
expect(subject).to include('table', '/table')
end
it 'should render empty header' do
expect(subject).to include('')
end
it 'should render empty body' do
expect(subject).to include('No records found')
end
end
describe 'Table with header' do
let(:header) { ['Title', 'Description'] }
let(:columns) { [] }
subject { render_table_for(table_header: header, columns: columns) }
it 'should render header data' do
expect(subject).to include(' ')
end
end
describe 'Table with columns' do
let(:header) { [] }
let(:columns) { [[1, 'first line'], [2, 'second line']] }
subject { render_table_for(table_header: header, columns: columns) }
it 'should render columns data' do
expect(subject).to include('Title Description