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 +1 -1
- data/bin/fixturease.rb +11 -8
- data/spec/fixturease_spec.rb +1 -1
- metadata +1 -1
data/Rakefile
CHANGED
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)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
data/spec/fixturease_spec.rb
CHANGED
@@ -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'"
|