fixture_background 0.9.4 → 0.9.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.
@@ -16,7 +16,9 @@ module FixtureBackground
|
|
16
16
|
"#{parent_class.name}"
|
17
17
|
end
|
18
18
|
EOT
|
19
|
-
|
19
|
+
|
20
|
+
background_to_use.generate!
|
21
|
+
|
20
22
|
klass.fixture_path = background_to_use.fixture_path
|
21
23
|
klass.fixtures :all
|
22
24
|
|
@@ -39,7 +41,11 @@ module FixtureBackground
|
|
39
41
|
@parent = parent
|
40
42
|
@background_block = blk
|
41
43
|
|
42
|
-
Generator.new(@full_class_name, background_signature, fixture_path, ancestors_and_own_background_blocks, @test_unit_class) unless background_valid?
|
44
|
+
@generator = Generator.new(@full_class_name, background_signature, fixture_path, ancestors_and_own_background_blocks, @test_unit_class) unless background_valid?
|
45
|
+
end
|
46
|
+
|
47
|
+
def generate!
|
48
|
+
@generator.generate! if @generator
|
43
49
|
end
|
44
50
|
|
45
51
|
def ancestors_and_own_background_blocks
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module FixtureBackground
|
2
2
|
class Generator
|
3
3
|
def initialize(fixture_name, version, background_dir, blocks, test_unit_class)
|
4
|
-
@background_dir = background_dir
|
5
|
-
|
6
|
-
|
4
|
+
@fixture_name, @version, @background_dir, @blocks, @test_unit_class = fixture_name, version, background_dir, blocks, test_unit_class
|
5
|
+
end
|
6
|
+
|
7
|
+
def generate!
|
7
8
|
remove_background_dir
|
8
9
|
create_background_dir
|
9
10
|
|
@@ -19,7 +20,7 @@ module FixtureBackground
|
|
19
20
|
|
20
21
|
bm = Benchmark.realtime do
|
21
22
|
dump_ivars do |klass|
|
22
|
-
blocks.each do |block|
|
23
|
+
@blocks.each do |block|
|
23
24
|
klass.instance_eval(&block)
|
24
25
|
end
|
25
26
|
end
|
@@ -27,10 +28,10 @@ module FixtureBackground
|
|
27
28
|
end
|
28
29
|
|
29
30
|
File.open("#{@background_dir}/.version", 'w+') do |f|
|
30
|
-
f.write version
|
31
|
+
f.write @version
|
31
32
|
end
|
32
33
|
|
33
|
-
puts "Instanciating #{fixture_name} took #{bm}ms"
|
34
|
+
puts "Instanciating #{@fixture_name} took #{bm}ms"
|
34
35
|
end
|
35
36
|
rescue Exception
|
36
37
|
remove_background_dir
|
@@ -21,7 +21,7 @@ module Shoulda
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def background(&blk)
|
24
|
-
@fixture_background = FixtureBackground::Background.new(full_class_name, test_unit_class, parent_fixture_background, blk)
|
24
|
+
@fixture_background = FixtureBackground::Background.new(full_class_name, test_unit_class, parent_fixture_background, blk)
|
25
25
|
end
|
26
26
|
|
27
27
|
def class_for_test
|
@@ -1,14 +1,21 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class PersonTest < ActiveSupport::TestCase
|
4
|
+
|
4
5
|
background do
|
5
6
|
some_test_helper_returning_one
|
7
|
+
instance_test_helper_defined_after_background_returning_one
|
6
8
|
@hase = Person.create(:name => "bunny")
|
7
9
|
end
|
8
10
|
|
11
|
+
def instance_test_helper_defined_after_background_returning_one
|
12
|
+
1
|
13
|
+
end
|
14
|
+
|
9
15
|
context "with thies" do
|
10
16
|
background do
|
11
17
|
some_test_helper_returning_one
|
18
|
+
instance_test_helper_defined_after_background_returning_one
|
12
19
|
@thies = Person.create(:name => "thies")
|
13
20
|
end
|
14
21
|
|
@@ -56,4 +63,8 @@ class PersonTest < ActiveSupport::TestCase
|
|
56
63
|
assert_equal 2, Person.count
|
57
64
|
end
|
58
65
|
end
|
66
|
+
|
67
|
+
protected
|
68
|
+
|
69
|
+
|
59
70
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
8
|
+
- 5
|
9
|
+
version: 0.9.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Thies C. Arntzen
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-04-05 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|