data_seeder 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -60,6 +60,29 @@ describe DataSeeder, :model do
60
60
  end
61
61
  end
62
62
 
63
+ describe 'when run with use_line_number_as_id' do
64
+ before do
65
+ @name = "test.use_line_number_as_id"
66
+ @file = "states.csv"
67
+ @seed_dir = setup_seed_dir(@name, @file)
68
+ end
69
+
70
+ after do
71
+ cleanup_seed_dir(@name)
72
+ end
73
+
74
+ it 'should use the line number as the id' do
75
+ modify_seed_file(@name, 'states.csv') do |body|
76
+ # Remove the id column
77
+ body.gsub(/^.*?,/,'')
78
+ end
79
+ File.open(seed_file_name(@name, 'states.cfg'), 'w') {|f| f.write '{ use_line_number_as_id: true }'}
80
+ DataSeeder.run(seed_dir: @seed_dir)
81
+ assert_equal 'AK', State.find(1).code
82
+ assert_equal 'WY', State.find(50).code
83
+ end
84
+ end
85
+
63
86
  describe 'when run with a custom loader' do
64
87
  before do
65
88
  @name = 'test.custom'
@@ -127,6 +150,8 @@ describe DataSeeder, :model do
127
150
 
128
151
  def cleanup_seed_dir(name)
129
152
  FileUtils.rm_rf(seed_dir_name(name))
153
+ # Reset config stuff
154
+ DataSeeder.reset
130
155
  end
131
156
 
132
157
  def modify_seed_file(name, file, &block)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_seeder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Pardee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-15 00:00:00.000000000 Z
11
+ date: 2015-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails