# encoding: UTF-8 require 'spec_helper' ActionView::Base.send :include, TableGo::Helpers describe TableGo::Helpers 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) { action_view_instance } describe 'integration in haml template' do let(:subject) do Haml::Engine.new(read_file_from_fixtures_path('simple_table.html.haml')).render(template, :articles => articles) end it "it should render in haml" do subject.cleanup_html.should eql %Q(

Suppe

Ident Custom single cell Custom multiline cell Custom single cell with backwards compatibility field with_html_markup
1 Ident: 1 - Title: iPutz Ident: 1 - Title: iPutz Ident: 1 click me
and here
2 Ident: 2 - Title: Nutzbook Ident: 2 - Title: Nutzbook Ident: 2 click me
and here

Pampe

).cleanup_html end end describe 'integration in haml template for a table_rows_for' do let(:subject) do Haml::Engine.new(read_file_from_fixtures_path('table_rows_for.html.haml')).render(template, :articles => articles.first) end it "it should render in haml" do subject.cleanup_html.should eql %Q( 1 Ident: 1 - Title: iPutz Ident: 1 - Title: iPutz Ident: 1 click me
and here ).cleanup_html end end describe 'integration in haml template for a table_go_for with options render_rows_only "true"' do let(:subject) do Haml::Engine.new(read_file_from_fixtures_path('table_go_for_with_only_rows.html.haml')). render(template, :articles => articles.first) end it "it should render in haml" do subject.cleanup_html.should eql %Q( 1 Ident: 1 - Title: iPutz Ident: 1 - Title: iPutz Ident: 1 click me
and here ).cleanup_html end end describe 'integration in haml template for a table_go_for with options without_header "true"' do let(:subject) do Haml::Engine.new(read_file_from_fixtures_path('table_go_for_without_header.html.haml')). render(template, :articles => articles.first) end it "it should render in haml" do subject.cleanup_html.should eql %Q(
1 Ident: 1 - Title: iPutz Ident: 1 - Title: iPutz Ident: 1 click me
and here
).cleanup_html end end # context 'speedtest' do # let(:more_articles) { 1000.times.map { articles }.flatten } # it 'should run fast' do # puts Benchmark.measure { # 2.times do # Haml::Engine.new(read_file_from_fixtures_path('simple_table.html.haml')).render(template, :articles => more_articles) # end # } # end # end end