fixturease 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ desc 'Default: run unit tests.'
7
7
  task :default => :spec
8
8
 
9
9
 
10
- PKG_VERSION="0.2.4"
10
+ PKG_VERSION="0.2.5"
11
11
  PKG_FILES=["bin/fixturease.rb","Rakefile","spec/database.yml","spec/fixturease_spec.rb"]
12
12
 
13
13
  spec = Gem::Specification.new do |s|
data/bin/fixturease.rb CHANGED
@@ -18,18 +18,21 @@ else
18
18
  Fixtures.create_fixtures(ENV['RAILS_ROOT']+'/'+ENV['FIXTURES_ROOT'], File.basename(fixture_file,".yml"))
19
19
  model = File.basename(fixture_file,".yml").singularize.camelize.constantize
20
20
  model.find(:all).each {|o| o.save_for_fixturease }
21
- YAML::load_file(fixture_file).each_pair do |name,obj|
22
- case name
23
- when /^#{File.basename(fixture_file,".yml")}$/
24
- # unnamed, skip
25
- else
26
- # if named
27
- instance_variable_set("@#{name}",model.find(obj["id"]))
21
+ yaml = YAML::load_file(fixture_file)
22
+ if yaml.is_a? Hash
23
+ yaml.each_pair do |name,obj|
24
+ case name
25
+ when /^#{File.basename(fixture_file,".yml")}$/
26
+ # unnamed, skip
27
+ else
28
+ # if named
29
+ instance_variable_set("@#{name}",model.find(obj["id"]))
30
+ end
28
31
  end
29
32
  end
30
33
  end
31
34
  end
32
-
35
+
33
36
 
34
37
  class ActiveRecord::Base
35
38
  alias_method :save_orig, :save
@@ -112,7 +112,7 @@ context "Fixturease" do
112
112
  new_yaml = YAML::load_file("testfixtureaseproject/test/fixtures/test_models.yml")
113
113
  new_yaml.should == original_yaml
114
114
  end
115
-
115
+
116
116
  specify "should rewrite fixtures from scratch if -l command line option" do
117
117
  run_fixturease do |f|
118
118
  f.puts "@test = TestModel.create :title => 'test title'"
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: fixturease
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.4
6
+ version: 0.2.5
7
7
  date: 2007-01-20 00:00:00 +02:00
8
8
  summary: Easy fixture creation tool
9
9
  require_paths: