Sha256: d046d771bf80bf14130ea3c9e9890865863ba3731773b4a2de9e6f53284a64c3
Contents?: true
Size: 1.15 KB
Versions: 6
Compression:
Stored size: 1.15 KB
Contents
require 'pathname' require Pathname(__FILE__).dirname.parent.expand_path + 'spec_helper' require 'fastercsv' describe DataMapper::Types::Csv, ".load" do it 'should parse the value if a string is provided' do FasterCSV.should_receive(:parse).with('csv_string').once DataMapper::Types::Csv.load('csv_string', :property) end it 'should do nothing if the value is a string' do FasterCSV.should_not_receive(:parse) DataMapper::Types::Csv.load([], :property).should == [] end it 'should return nil otherwise' do DataMapper::Types::Csv.load({}, :property).should == nil DataMapper::Types::Csv.load(nil, :property).should == nil end end describe DataMapper::Types::Csv, ".dump" do it 'should dump to CSV' do DataMapper::Types::Csv.dump([[1, 2, 3]], :property).should == "1,2,3\n" end it 'should do nothing if the value is a string' do FasterCSV.should_not_receive(:generate) DataMapper::Types::Csv.dump('string', :property).should == 'string' end it 'should return nil otherwise' do DataMapper::Types::Csv.dump({}, :property).should == nil DataMapper::Types::Csv.dump(nil, :property).should == nil end end
Version data entries
6 entries across 6 versions & 1 rubygems