Sha256: 5bd206ce2e13696badb225ee17e96a1c0bada5f564f62c0d3c24e65baf436b68

Contents?: true

Size: 975 Bytes

Versions: 1

Compression:

Stored size: 975 Bytes

Contents

# encoding: utf-8
#
require 'spec_helper'

describe Mode::Sdk::CsvFile do
  let :file do
    Mode::Sdk::CsvFile.new(test_file_path('population_growth.csv'))
  end

  describe '#name' do
    it 'returns name without csv extension' do
      expect(file.name).to eq('population_growth')
    end
  end

  describe '#size' do
    it 'returns size' do
      expect(file.size).to be_an_instance_of(Fixnum)
    end
  end

  describe '#lines' do
    it 'parses csv' do
      expect(file.lines).to be_an_instance_of(Array)
      expect(file.lines.size).to eq(10)
    end
  end

  describe '#line_count' do
    it 'returns line count' do
      expect(file.line_count).to eq(10)
    end
  end

  describe '#header' do
    it 'parses header' do
      expect(file.header).to eq(%w(date value))
    end
  end

  describe '#content' do
    it 'returns content' do
      expect(file.content).to be_an_instance_of(String)
      expect(file.content.scan(/\n/).count).to eq(8)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mode-sdk-0.1.0 spec/lib/mode/sdk/csv_file_spec.rb