spec/public/to_csv_spec.rb in dm-serializer-0.10.2 vs spec/public/to_csv_spec.rb in dm-serializer-1.0.0.rc1
- old
+ new
@@ -33,29 +33,37 @@
result = @collection.to_csv.gsub(/[[:space:]]+\n/, "\n")
result.split("\n")[0].split(',')[0..3].should == ['1','2','Betsy','Jersey']
result.split("\n")[1].split(',')[0..3].should == ['10','20','Berta','Guernsey']
end
- it 'should integration with dm-validations by providing one line per error' do
+ it 'should integrate with dm-validations by providing one line per error' do
planet = Planet.create(:name => 'a')
result = planet.errors.to_csv.gsub(/[[:space:]]+\n/, "\n").split("\n")
result.should include("name,#{planet.errors[:name][0]}")
result.should include("solar_system_id,#{planet.errors[:solar_system_id][0]}")
result.length.should == 2
end
- describe "multiple repositories" do
- before(:all) do
- QuanTum::Cat.auto_migrate!
- DataMapper.repository(:alternate){ QuanTum::Cat.auto_migrate! }
- end
+ with_alternate_adapter do
- it "should use the repsoitory for the model" do
- gerry = QuanTum::Cat.create(:name => "gerry")
- george = DataMapper.repository(:alternate){ QuanTum::Cat.create(:name => "george", :is_dead => false) }
- gerry.to_csv.should_not match(/false/)
- george.to_csv.should match(/false/)
+ describe "multiple repositories" do
+ before(:all) do
+ [ :default, :alternate ].each do |repository_name|
+ DataMapper.repository(repository_name) do
+ QuanTum::Cat.auto_migrate!
+ QuanTum::Cat.all.destroy!
+ end
+ end
+ end
+
+ it "should use the repsoitory for the model" do
+ gerry = QuanTum::Cat.create(:name => "gerry")
+ george = DataMapper.repository(:alternate){ QuanTum::Cat.create(:name => "george", :is_dead => false) }
+ gerry.to_csv.should_not match(/false/)
+ george.to_csv.should match(/false/)
+ end
end
+
end
end
else
warn "[WARNING] Cannot require 'faster_csv' or 'csv', not running #to_csv specs"
end