test_seeds 0.0.3 → 0.0.4
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/VERSION +1 -1
- data/lib/test_seeds.rb +9 -3
- data/test/test_test_seeds.rb +18 -3
- data/test_seeds.gemspec +2 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/lib/test_seeds.rb
CHANGED
@@ -83,7 +83,7 @@ module TestSeeds
|
|
83
83
|
|
84
84
|
setup_seeds(nil)
|
85
85
|
else
|
86
|
-
|
86
|
+
fixtures_class_in_my_rails.reset_cache
|
87
87
|
@@already_loaded_fixtures[self.class] = nil
|
88
88
|
@loaded_fixtures = load_fixtures
|
89
89
|
end
|
@@ -98,7 +98,7 @@ module TestSeeds
|
|
98
98
|
return unless defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank?
|
99
99
|
|
100
100
|
unless run_in_transaction?
|
101
|
-
|
101
|
+
fixtures_class_in_my_rails.reset_cache
|
102
102
|
end
|
103
103
|
|
104
104
|
if run_in_transaction? && @created_save_point
|
@@ -113,7 +113,7 @@ module TestSeeds
|
|
113
113
|
# Load fixture is called once for each test class which is a good place to inject db transactions
|
114
114
|
# and to create the seeds.
|
115
115
|
def load_fixtures
|
116
|
-
if
|
116
|
+
if ActiveRecord::Base.connection.open_transactions != 0
|
117
117
|
ActiveRecord::Base.connection.decrement_open_transactions
|
118
118
|
ActiveRecord::Base.connection.rollback_db_transaction
|
119
119
|
end
|
@@ -169,4 +169,10 @@ module TestSeeds
|
|
169
169
|
_run_seed_callbacks
|
170
170
|
end
|
171
171
|
end
|
172
|
+
|
173
|
+
private
|
174
|
+
|
175
|
+
def fixtures_class_in_my_rails
|
176
|
+
ActiveRecord.const_defined?(:Fixtures) ? ActiveRecord::Fixtures : Fixtures
|
177
|
+
end
|
172
178
|
end
|
data/test/test_test_seeds.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestTestSeeds < ActiveSupport::TestCase
|
4
|
-
include TestSeeds
|
5
|
-
|
6
4
|
fixtures :authors
|
5
|
+
include TestSeeds
|
7
6
|
|
8
7
|
seeds do
|
9
8
|
@default_1 = Author.create!(:name => 'default first')
|
@@ -67,13 +66,29 @@ class TestTestSeeds < ActiveSupport::TestCase
|
|
67
66
|
assert_not_nil authors(:actual_fixture)
|
68
67
|
assert_equal "Bob Dole", authors(:actual_fixture).name
|
69
68
|
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
class TestTestSeeds2 < ActiveSupport::TestCase
|
73
|
+
self.use_transactional_fixtures = false
|
74
|
+
|
75
|
+
fixtures :authors
|
76
|
+
include TestSeeds
|
77
|
+
|
78
|
+
def test_is_not_affected_by_previous_tests
|
79
|
+
assert_equal [authors(:actual_fixture)], Author.all.to_a
|
80
|
+
end
|
70
81
|
|
71
82
|
end
|
72
83
|
|
73
84
|
class TestTestSeedsWithoutSeedSet < ActiveSupport::TestCase
|
85
|
+
|
86
|
+
fixtures :authors
|
74
87
|
include TestSeeds
|
75
88
|
|
76
89
|
def test_does_not_blow_up_when_test_seeds_is_not_used
|
77
90
|
assert true
|
78
91
|
end
|
79
|
-
end
|
92
|
+
end
|
93
|
+
|
94
|
+
|
data/test_seeds.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{test_seeds}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Paul Kmiec}]
|
12
|
-
s.date = %q{2011-08-
|
12
|
+
s.date = %q{2011-08-19}
|
13
13
|
s.description = %q{Test Seeds piggy backs on the transaction fixtures functionality. Test Seeds load fixtures into the database in the same way but then start a db transaction for the duration of the test file. Any objects for the common scenarios are then created and inserted into the database. Test Seeds then execute each test case within a context of a db savepoint (or nested db transactions). This allows test seeds to be inserted into the database once and then re-used for each test case that needs it.}
|
14
14
|
s.email = %q{pkmiec@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_seeds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Paul Kmiec
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-08-
|
18
|
+
date: 2011-08-19 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
requirement: &id001 !ruby/object:Gem::Requirement
|