fixturease 0.2.9 → 0.3
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 +5 -0
- data/spec/fixturease_spec.rb +46 -23
- metadata +2 -2
data/Rakefile
CHANGED
data/bin/fixturease.rb
CHANGED
data/spec/fixturease_spec.rb
CHANGED
|
@@ -8,11 +8,19 @@ context "Fixturease" do
|
|
|
8
8
|
FileUtils.rm_rf 'testfixtureaseproject'
|
|
9
9
|
`rails testfixtureaseproject`
|
|
10
10
|
FileUtils.cp File.dirname(__FILE__)+'/database.yml','testfixtureaseproject/config/database.yml'
|
|
11
|
-
`cd testfixtureaseproject && ./script/generate model TestModel title:string`
|
|
11
|
+
`cd testfixtureaseproject && ./script/generate model TestModel title:string another_model_id:integer`
|
|
12
|
+
`cd testfixtureaseproject && ./script/generate model AnotherModel title:string`
|
|
13
|
+
File.open('testfixtureaseproject/app/models/test_model.rb','w') do |f|
|
|
14
|
+
f.write "
|
|
15
|
+
class TestModel < ActiveRecord::Base
|
|
16
|
+
belongs_to :another_model
|
|
17
|
+
end
|
|
18
|
+
"
|
|
19
|
+
end
|
|
12
20
|
`cd testfixtureaseproject && rake db:migrate RAILS_ENV=test`
|
|
13
21
|
cleanup_fixtures
|
|
14
22
|
end
|
|
15
|
-
|
|
23
|
+
|
|
16
24
|
teardown do
|
|
17
25
|
FileUtils.rm_rf 'testfixtureaseproject'
|
|
18
26
|
end
|
|
@@ -24,7 +32,7 @@ context "Fixturease" do
|
|
|
24
32
|
f.readline until f.eof?
|
|
25
33
|
end
|
|
26
34
|
end
|
|
27
|
-
|
|
35
|
+
|
|
28
36
|
|
|
29
37
|
specify "should create empty TestModel" do
|
|
30
38
|
run_fixturease do |f|
|
|
@@ -50,6 +58,21 @@ context "Fixturease" do
|
|
|
50
58
|
yaml[key]["title"].should == 'test title'
|
|
51
59
|
end
|
|
52
60
|
|
|
61
|
+
specify "should create TestModel with title and another_model" do
|
|
62
|
+
run_fixturease do |f|
|
|
63
|
+
f.puts "TestModel.create :title => 'test title', :another_model => AnotherModel.create(:title=>'hello')"
|
|
64
|
+
f.puts "exit"
|
|
65
|
+
f.readline until f.eof?
|
|
66
|
+
end
|
|
67
|
+
ayaml = YAML::load_file("testfixtureaseproject/test/fixtures/another_models.yml")
|
|
68
|
+
yaml = YAML::load_file("testfixtureaseproject/test/fixtures/test_models.yml")
|
|
69
|
+
yaml.keys.should_have(1).grep(/test_models_(\d)+/)
|
|
70
|
+
key = yaml.keys.grep(/test_models_(\d)+/).first
|
|
71
|
+
akey = ayaml.keys.grep(/another_models_(\d)+/).first
|
|
72
|
+
yaml[key]["title"].should == 'test title'
|
|
73
|
+
yaml[key]["another_model_id"].should == ayaml[akey]["id"]
|
|
74
|
+
end
|
|
75
|
+
|
|
53
76
|
specify "should not create destroyed model" do
|
|
54
77
|
run_fixturease do |f|
|
|
55
78
|
f.puts "@test1 = TestModel.create :title => 'test title'"
|
|
@@ -64,24 +87,24 @@ context "Fixturease" do
|
|
|
64
87
|
end
|
|
65
88
|
|
|
66
89
|
specify "should not create unsaved model" do
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
run_fixturease do |f|
|
|
91
|
+
f.puts "@test1 = TestModel.new :title => 'test title'"
|
|
92
|
+
f.puts "exit"
|
|
93
|
+
f.readline until f.eof?
|
|
94
|
+
end
|
|
95
|
+
yaml = YAML::load_file("testfixtureaseproject/test/fixtures/test_models.yml")
|
|
96
|
+
yaml.should == false
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
specify "should ignore non-ActiveRecord instance variables" do
|
|
100
|
+
run_fixturease do |f|
|
|
101
|
+
f.puts "@test1 = 1"
|
|
102
|
+
f.puts "exit"
|
|
103
|
+
f.readline until f.eof?
|
|
104
|
+
end
|
|
105
|
+
yaml = YAML::load_file("testfixtureaseproject/test/fixtures/test_models.yml")
|
|
106
|
+
yaml.should == false
|
|
107
|
+
end
|
|
85
108
|
|
|
86
109
|
specify "should create named model according to instance variable name" do
|
|
87
110
|
run_fixturease do |f|
|
|
@@ -129,7 +152,7 @@ context "Fixturease" do
|
|
|
129
152
|
new_yaml = YAML::load_file("testfixtureaseproject/test/fixtures/test_models.yml")
|
|
130
153
|
new_yaml.should == original_yaml
|
|
131
154
|
end
|
|
132
|
-
|
|
155
|
+
|
|
133
156
|
specify "should rewrite fixtures from scratch with altered models if load_fixtures!" do
|
|
134
157
|
run_fixturease do |f|
|
|
135
158
|
f.puts "@test = TestModel.create :title => 'test title'"
|
|
@@ -184,7 +207,7 @@ context "Fixturease" do
|
|
|
184
207
|
def cleanup_fixtures()
|
|
185
208
|
`echo -n > testfixtureaseproject/test/fixtures/test_models.yml`
|
|
186
209
|
end
|
|
187
|
-
|
|
210
|
+
|
|
188
211
|
def run_fixturease(stropt=nil,&block)
|
|
189
212
|
ENV['RAILS_ROOT']='testfixtureaseproject'
|
|
190
213
|
ENV['FIXTURES_ROOT']='test/fixtures'
|
metadata
CHANGED
|
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
|
3
3
|
specification_version: 1
|
|
4
4
|
name: fixturease
|
|
5
5
|
version: !ruby/object:Gem::Version
|
|
6
|
-
version: 0.
|
|
7
|
-
date: 2007-02-
|
|
6
|
+
version: "0.3"
|
|
7
|
+
date: 2007-02-05 00:00:00 +02:00
|
|
8
8
|
summary: Easy fixture creation tool
|
|
9
9
|
require_paths:
|
|
10
10
|
- lib
|