Sha256: 2d6feb15a592fbb9c76a44d1669e13bb36779af2b899b8f4552fad77ef2f276c
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
require File.join(File.dirname(__FILE__), '..', %w[spec_helper]) require "dm-core" DataMapper.setup(:default, 'sqlite3::memory:') class Cat include DataMapper::Resource property :id, Serial property :name, String property :age, Integer include CheapImports end class Appointment include DataMapper::Resource property :id, Serial property :cat_id, Integer property :starts_at, DateTime include CheapImports imports :legacy_data => { :starts_at => "APPOINTMENT START TIME", :starts_at_format => "%d %b %Y %H:%M", :cat_name => "ANIMAL IDENTIFIER" } end DataMapper.auto_migrate! describe Cat, "importing default" do it "should import without any config" do data = %{name\tage\nFluffy\t7} imported_cats = Import.import(Cat, data) cats_named_fluffy = Cat.all(:name => "Fluffy") cats_named_fluffy.should have(1).items cats_named_fluffy.first.age.should eql(7) end end describe Appointment, "importing a specified config" do it "should description" do data = %{ANIMAL IDENTIFIER,APPOINTMENT START TIME\n} data << %{Fluffy,5 Jan 2009 10:30\n} appointments = Import.import(Appointment, data) a = appointments.first a.starts_at.should eql(DateTime.new(2009, 1, 5, 10, 30)) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cheap_imports-0.0.3 | spec/orms/datamapper_spec.rb |
cheap_imports-0.0.2 | spec/orms/datamapper_spec.rb |