# encoding: UTF-8 require 'spec_helper' describe TableGo::Renderers::HtmlRenderer do let(:articles) do [ Article.new(:title => 'iPutz', :date_of_order => Date.new(2012), :ident => 1, :vat => 19, :price => 5, :xmas_bonus => true, :my_type => 'super_type'), Article.new(:title => 'Nutzbook', :date_of_order => Date.new(2012), :ident => 2, :vat => 19, :price => 5, :xmas_bonus => false, :my_type => 'hardware_type') ] end let(:template) do ActionView::Base.new.tap do |view| view.output_buffer = ActiveSupport::SafeBuffer.new rescue '' end end describe 'automatic mode' do subject { TableGo.render_html(articles, Article, template, {}) } it 'should render a simple automatic html table' do subject.cleanup_html.should == %Q(
Ident | Title | Date of order | Vat | Price | Xmas bonus | My type |
---|---|---|---|---|---|---|
1 | iPutz | 2012-01-01 | 19 | 5 | true | super_type |
2 | Nutzbook | 2012-01-01 | 19 | 5 | false | hardware_type |
Ident | as percent | as € currency | Date of order | Date of order | with custom formatter | with block level custom formatter | as boolean | My type |
---|---|---|---|---|---|---|---|---|
1 | 19.000% | $5.00 | 2012-01-01 | Jan 01 | 10-10-2102 | a special value |
✔ | Super Type |
2 | 19.000% | $5.00 | 2012-01-01 | Jan 01 | 10-10-2102 | a special value |
✘ | Hardware Type |