Permalink
Browse files

fixing weird ruby1.8 bug

  • Loading branch information...
1 parent 780b7ac commit 181508367f5aa74d7882a1ce5e68d0c78ac3c8bc @gotascii committed Oct 23, 2009
Showing with 16 additions and 7 deletions.
  1. +4 −0 importers/crazy.rb
  2. +6 −1 lib/simple_importer.rb
  3. +6 −6 test/test_simple_importer.rb
View
@@ -1,3 +1,7 @@
+# require 'lib/simple_importer'
+# SimpleImporter.find_importers
+# SimpleImporter.importers.first.run
+
importer :crazy do
file 'data/people.csv'
callbacks true
View
@@ -75,7 +75,12 @@ def config
end
def csv_config
- config.select{|k,v| SimpleImporter.csv_config_meths.include?(k)}
+ ret = {}
+ config.each do |k, v|
+ ret[k] = config[k] if SimpleImporter.csv_config_meths.include?(k)
+ end
+ ret
+ # config.select{|k,v| SimpleImporter.csv_config_meths.include?(k)}
end
def run
@@ -56,6 +56,12 @@ class SimpleImporterTest < Test::Unit::TestCase
end
end
+ should "return the right gd hash for csv_config" do
+ SimpleImporter.stubs(:csv_config_meths).returns([:one, :two])
+ @importer.stubs(:config).returns({:one => 1, :two => 2, :three => 3})
+ @importer.csv_config.should == {:one => 1, :two => 2}
+ end
+
should "have fields for every CSV::DEFAULT_OPTIONS" do
CSV::DEFAULT_OPTIONS.keys.each do |meth|
@importer.send(meth, 'val')
@@ -125,12 +131,6 @@ class SimpleImporterTest < Test::Unit::TestCase
@importer.run
end
- # run_callbacks
- # [file].flatten.each do |f|
- # foreach_file.call(f) if foreach_file
- # CSV.foreach(f, csv_config, &foreach) if foreach
- # end
-
should "call CSV.foreach with file, csv_config when run" do
@importer.stubs(:foreach).returns(lambda{})
@importer.stubs(:file).returns('file')

0 comments on commit 1815083

Please sign in to comment.