fixture_background 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -17,10 +17,23 @@ module FixtureBackground
|
|
17
17
|
end
|
18
18
|
EOT
|
19
19
|
|
20
|
-
|
20
|
+
klass.class_eval <<-EOT
|
21
|
+
cattr_accessor :fixture_background
|
22
|
+
@@background_generated = false
|
23
|
+
|
24
|
+
def initialize(*args)
|
25
|
+
super
|
26
|
+
|
27
|
+
if (background = fixture_background) && !@@background_generated
|
28
|
+
background.generate!
|
29
|
+
@@background_generated = true
|
30
|
+
self.class.fixtures :all
|
31
|
+
end
|
32
|
+
end
|
33
|
+
EOT
|
21
34
|
|
35
|
+
klass.fixture_background = background_to_use
|
22
36
|
klass.fixture_path = background_to_use.fixture_path
|
23
|
-
klass.fixtures :all
|
24
37
|
|
25
38
|
Object.const_set(full_class_name, klass)
|
26
39
|
end
|
data/test/rails3/Gemfile.lock
CHANGED
@@ -8,10 +8,6 @@ class PersonTest < ActiveSupport::TestCase
|
|
8
8
|
@hase = Person.create(:name => "bunny")
|
9
9
|
end
|
10
10
|
|
11
|
-
def instance_test_helper_defined_after_background_returning_one
|
12
|
-
1
|
13
|
-
end
|
14
|
-
|
15
11
|
context "with thies" do
|
16
12
|
background do
|
17
13
|
some_test_helper_returning_one
|
@@ -26,7 +22,7 @@ class PersonTest < ActiveSupport::TestCase
|
|
26
22
|
assert_nil @norman
|
27
23
|
assert_equal 2, Person.count
|
28
24
|
end
|
29
|
-
|
25
|
+
|
30
26
|
context "with manuel" do
|
31
27
|
background do
|
32
28
|
@manuel = Person.create(:name => "manuel")
|
@@ -54,7 +50,7 @@ class PersonTest < ActiveSupport::TestCase
|
|
54
50
|
end
|
55
51
|
end
|
56
52
|
end
|
57
|
-
|
53
|
+
|
58
54
|
should "nother truth" do
|
59
55
|
assert @hase
|
60
56
|
assert @thies
|
@@ -63,8 +59,9 @@ class PersonTest < ActiveSupport::TestCase
|
|
63
59
|
assert_equal 2, Person.count
|
64
60
|
end
|
65
61
|
end
|
66
|
-
|
67
|
-
|
68
|
-
|
62
|
+
|
63
|
+
def instance_test_helper_defined_after_background_returning_one
|
64
|
+
1
|
65
|
+
end
|
69
66
|
|
70
67
|
end
|