Sha256: 9e33bb927104a675cf200be9c3703594014fbf1a93b643dbb30e0ea293137f71

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

# 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) do
    ActionView::Base.new.tap do |view|
      view.output_buffer = ActiveSupport::SafeBuffer.new rescue ''
    end
  end


  describe 'integtation in haml template' do

    let(:subject) do
      Haml::Engine.new(read_file_from_fixtures_path('simple_table.html.haml'))
    end


   it "description" do
      subject.render(template, :articles => articles).cleanup_html.should == %Q(
        <table>
          <thead>
            <tr>
              <th>Ident</th>
              <th>Custom single cell</th>
              <th>Custom multiline cell</th>
              <th>Custom single cell with backwards compatibility</th>
            </tr></thead>
          <tbody>
            <tr>
              <td>1</td>
              <td>Ident: 1 - Title: iPutz</td>
              <td>Ident: 1 - Title: iPutz</td>
              <td>Ident: 1</td>
            </tr>
            <tr>
              <td>2</td>
              <td>Ident: 2 - Title: Nutzbook</td>
              <td>Ident: 2 - Title: Nutzbook</td>
              <td>Ident: 2</td>
            </tr>
          </tbody>
        </table>
      ).cleanup_html
    end


  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
table_go-0.2.0 spec/table_go/helper_spec.rb