Sha256: f87863e39bc1e5792d3fbecd7bf63c8b9f5ebfc5bd5736e7c6f276d3044d4f28

Contents?: true

Size: 1.87 KB

Versions: 2

Compression:

Stored size: 1.87 KB

Contents

require 'spec_helper'
module Alf
  module CSV
    describe Renderer do
    
      describe "without options" do
        let(:input){ 
          [{:size => 10}, {:size => 20}]
        }
        let(:expected){
          "size\n10\n20\n"
        }
        subject{ renderer.execute(StringIO.new).string }
          
        describe "when called on a renderer directly" do
          let(:renderer){
            ::Alf::CSV::Renderer.new(input)
          }
          it{ should eq(expected) }
        end
        
        describe "when called through registererd one" do
          let(:renderer){
            ::Alf::Renderer.renderer(:csv, input)
          }
          it{ should eq(expected) }
        end
        
        describe "when called through factory method" do
          let(:renderer){
            ::Alf::Renderer.csv(input)
          }
          it{ should eq(expected) }
        end
      end
      
      describe "with options" do
        let(:input){ 
          [{:size => 10, :name => "blambeau"}, {:size => 20, :name => "mmathieu"}]
        }
        let(:expected){
          "size;name\n10;blambeau\n20;mmathieu\n"
        }
        let(:options){
          {:col_sep => ";"}
        }
        subject{ renderer.execute(StringIO.new).string }
          
        describe "when called on a renderer directly" do
          let(:renderer){
            ::Alf::CSV::Renderer.new(input, options)
          }
          it{ should eq(expected) }
        end
        
        describe "when called through registererd one" do
          let(:renderer){
            ::Alf::Renderer.renderer(:csv, input, options)
          }
          it{ should eq(expected) }
        end
        
        describe "when called through factory method" do
          let(:renderer){
            ::Alf::Renderer.csv(input, options)
          }
          it{ should eq(expected) }
        end
      end
      
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alf-0.10.1 spec/unit/csv/test_renderer.rb
alf-0.10.0 spec/unit/csv/test_renderer.rb