Sha256: 56a155f9c7b1d97e94f70049758955c048d392366263739fa3191b95aeb6e652
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
require 'pathname' require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper' describe DataMapper::Serialize, '#to_csv' do # # ==== blah, it's CSV # before(:all) do query = DataMapper::Query.new(DataMapper::repository(:default), Cow) @collection = DataMapper::Collection.new(query) do |c| c.load([1, 2, 'Betsy', 'Jersey']) c.load([10, 20, 'Berta', 'Guernsey']) end @empty_collection = DataMapper::Collection.new(query) {} end it "should serialize a resource to CSV" do peter = Cow.new peter.id = 44 peter.composite = 344 peter.name = 'Peter' peter.breed = 'Long Horn' peter.to_csv.chomp.should == '44,344,Peter,Long Horn' end it "should serialize a collection to CSV" do @collection.to_csv.gsub(/[[:space:]]+\n/, "\n").should == "1,2,Betsy,Jersey\n" + "10,20,Berta,Guernsey\n" end describe "multiple repositories" do before(:all) do QuantumCat.auto_migrate! repository(:alternate){QuantumCat.auto_migrate!} end it "should use the repsoitory for the model" do gerry = QuantumCat.create(:name => "gerry") george = repository(:alternate){QuantumCat.create(:name => "george", :is_dead => false)} gerry.to_csv.should_not match(/false/) george.to_csv.should match(/false/) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dm-serializer-0.9.3 | spec/unit/to_csv_spec.rb |