Sha256: 11ff4dc609ce419f8527481dd94fb881119045b9cf4467ef007782e4030b0b77
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
require 'spec' require 'spec/spec_helper' require 'fastercsv' describe TableFu do before :all do @csv = <<-CSV Project,Cost,Date,URL Build Supercollider,500_000_000.50,09/15/2009,http://project.com Harness Power of Fusion,25_000_000,09/16/2009,http://project2.com Motorized Bar Stool,45.00,09/17/2009,http://project3.com CSV @spreadsheet = TableFu.new(@csv) do |s| s.formatting = {'Cost' => 'currency', 'Link' => {'method'=> 'link', 'arguments' => ['Project', 'URL']}} s.sorted_by = {'Project' => {'order' => 'descending'}} s.columns = ['Date', 'Project', 'Cost', 'Link'] end end it "should just work" do @spreadsheet.rows[0].column_for('Cost').to_s.should == '$45.00' @spreadsheet.rows[0].columns[1].to_s.should == 'Motorized Bar Stool' @spreadsheet.rows[0].column_for('Link').to_s.should == "<a href='http://project.com' title='Build Supercollider'>Build Supercollider</a>" end it 'should open a file if passed one' do @spreadsheet = TableFu.new(File.open('spec/assets/test.csv')).rows[0].column_for('State').to_s.should eql "Alabama" end it "should populate headers if we don't tell it which headers to use" do TableFu.new(@csv).headers.should_not be_nil end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
table_fu-0.1.1 | spec/readme_example_spec.rb |