Sha256: a009f5990159ec67e80531262b92f74d54ec76a7aa345dcc1e8d58293e4633ce
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
require 'spec_helper' require 'sepparator/spreadsheet_converter' require 'tempfile' require 'fileutils' describe Sepparator::SpreadsheetConverter do it 'remembers the column separator' do sep = 'foobar' expect(described_class.new(col_sep: sep).col_sep).to eq(sep) end context '#convert_from_string' do let(:csv_string) { File.open(File.join(__dir__, 'example.csv')).read } let(:xls_path) { Tempfile.new('convert-to-xlsx').path } subject { described_class.new.convert_from_string(csv_string, xls_path) } before { FileUtils.rm_f xls_path } it "converts a csv string" do # don't comparing xlsx files here subject expect(File.exists?(xls_path)).to be_true end it 'raises when the destination file already exists' do expect{described_class.new.convert('/some/non/existing/file.csv', Tempfile.new('blafoo').path)}.to raise_error(ArgumentError, /destination file exists/) end end context '#convert' do #let(:xls_path) { Tempfile.new('convert-to-xlsx')} let(:xls_path) { '/tmp/example.xlsx' } let(:csv_path) { File.join(__dir__, 'example.csv')} subject { described_class.new.convert(csv_path, xls_path)} before do FileUtils.rm_f xls_path end it 'converts a CSV file' do # don't comparing xlsx files here subject expect(File.exists?(xls_path)).to be_true end it 'raises when the source file was not found' do expect{described_class.new.convert('/some/non/existing/file.csv', xls_path)}.to raise_error(ArgumentError, /file not found/) end it 'raises when the destination file already exists' do expect{described_class.new.convert('/some/non/existing/file.csv', Tempfile.new('blafoo').path)}.to raise_error(ArgumentError, /destination file exists/) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sepparator-0.0.4 | spec/sepparator/spreadsheet_converter_spec.rb |