/
builder_spec.rb
34 lines (28 loc) · 1.11 KB
/
builder_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require 'spec_helper'
describe TableCloth::Builder do
subject { Class.new(TableCloth::Builder) }
let(:view_context) { ActionView::Base.new }
context '.build' do
it 'builds a table on the fly with a block' do
expect {|b| subject.build([], view_context, &b) }.to yield_control
end
it 'builds a table from a class name' do
new_table = subject.build([], view_context, with: DummyTable)
new_table.table.should == DummyTable
end
it 'defaults the presenter' do
new_table = subject.build([], view_context, with: DummyTable)
new_table.presenter.should be_kind_of TableCloth::Presenters::Default
end
it 'can provide a presenter' do
random_presenter = Class.new(TableCloth::Presenters::Default)
new_table = subject.build([], view_context, with: DummyTable, present_with: random_presenter)
new_table.presenter.should be_kind_of random_presenter
end
it '.to_s renders a table' do
new_table = subject.build([], view_context, with: DummyTable)
new_table.presenter.should_receive(:render_table).once
new_table.to_s
end
end
end