test_data 0.0.2 → 0.2.2

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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -5
  3. data/.standard.yml +2 -0
  4. data/CHANGELOG.md +41 -0
  5. data/Gemfile.lock +16 -16
  6. data/LICENSE.txt +1 -6
  7. data/README.md +864 -501
  8. data/example/.gitignore +1 -4
  9. data/example/Gemfile.lock +74 -74
  10. data/example/config/application.rb +3 -0
  11. data/example/config/credentials.yml.enc +1 -2
  12. data/example/spec/rails_helper.rb +1 -1
  13. data/example/spec/requests/boops_spec.rb +1 -5
  14. data/example/spec/requests/rails_fixtures_override_spec.rb +106 -0
  15. data/example/test/integration/better_mode_switching_demo_test.rb +6 -10
  16. data/example/test/integration/fixture_load_count_test.rb +82 -0
  17. data/example/test/integration/load_rollback_truncate_test.rb +40 -45
  18. data/example/test/integration/mode_switching_demo_test.rb +4 -14
  19. data/example/test/integration/parallel_boops_with_fixtures_test.rb +2 -6
  20. data/example/test/integration/parallel_boops_without_fixtures_test.rb +2 -6
  21. data/example/test/integration/rails_fixtures_double_load_test.rb +10 -0
  22. data/example/test/integration/rails_fixtures_override_test.rb +110 -0
  23. data/example/test/integration/test_data_hooks_test.rb +89 -0
  24. data/example/test/integration/transaction_committing_boops_test.rb +5 -3
  25. data/example/test/test_helper.rb +2 -6
  26. data/lib/generators/test_data/cable_yaml_generator.rb +18 -0
  27. data/lib/generators/test_data/database_yaml_generator.rb +2 -3
  28. data/lib/generators/test_data/environment_file_generator.rb +7 -0
  29. data/lib/generators/test_data/initializer_generator.rb +20 -7
  30. data/lib/generators/test_data/secrets_yaml_generator.rb +19 -0
  31. data/lib/generators/test_data/webpacker_yaml_generator.rb +3 -2
  32. data/lib/test_data.rb +37 -1
  33. data/lib/test_data/active_record_ext.rb +11 -0
  34. data/lib/test_data/config.rb +33 -3
  35. data/lib/test_data/configurators.rb +2 -0
  36. data/lib/test_data/configurators/cable_yaml.rb +25 -0
  37. data/lib/test_data/configurators/environment_file.rb +3 -2
  38. data/lib/test_data/configurators/initializer.rb +3 -2
  39. data/lib/test_data/configurators/secrets_yaml.rb +25 -0
  40. data/lib/test_data/configurators/webpacker_yaml.rb +4 -3
  41. data/lib/test_data/custom_loaders/abstract_base.rb +25 -0
  42. data/lib/test_data/custom_loaders/rails_fixtures.rb +45 -0
  43. data/lib/test_data/dumps_database.rb +24 -1
  44. data/lib/test_data/generator_support.rb +3 -0
  45. data/lib/test_data/inserts_test_data.rb +25 -0
  46. data/lib/test_data/loads_database_dumps.rb +1 -1
  47. data/lib/test_data/log.rb +19 -1
  48. data/lib/test_data/{transactional_data_loader.rb → manager.rb} +78 -81
  49. data/lib/test_data/rake.rb +16 -7
  50. data/lib/test_data/statistics.rb +6 -1
  51. data/lib/test_data/truncates_test_data.rb +31 -0
  52. data/lib/test_data/version.rb +1 -1
  53. data/script/reset_example_app +1 -0
  54. data/script/test +31 -6
  55. data/test_data.gemspec +1 -1
  56. metadata +20 -4
data/example/.gitignore CHANGED
@@ -18,7 +18,4 @@
18
18
  # Ignore master key for decrypting credentials and more.
19
19
  /config/master.key
20
20
 
21
- # Ignore files that are intentionally generated / asserted by the tests
22
- /config/environments/test_data.rb
23
- /test/support/test_data
24
- /db/migrate/20210418220133_add_beep_to_boops.rb
21
+
data/example/Gemfile.lock CHANGED
@@ -1,66 +1,66 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- test_data (0.0.2)
4
+ test_data (0.2.2)
5
5
  railties (~> 6.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (6.1.3.1)
11
- actionpack (= 6.1.3.1)
12
- activesupport (= 6.1.3.1)
10
+ actioncable (6.1.3.2)
11
+ actionpack (= 6.1.3.2)
12
+ activesupport (= 6.1.3.2)
13
13
  nio4r (~> 2.0)
14
14
  websocket-driver (>= 0.6.1)
15
- actionmailbox (6.1.3.1)
16
- actionpack (= 6.1.3.1)
17
- activejob (= 6.1.3.1)
18
- activerecord (= 6.1.3.1)
19
- activestorage (= 6.1.3.1)
20
- activesupport (= 6.1.3.1)
15
+ actionmailbox (6.1.3.2)
16
+ actionpack (= 6.1.3.2)
17
+ activejob (= 6.1.3.2)
18
+ activerecord (= 6.1.3.2)
19
+ activestorage (= 6.1.3.2)
20
+ activesupport (= 6.1.3.2)
21
21
  mail (>= 2.7.1)
22
- actionmailer (6.1.3.1)
23
- actionpack (= 6.1.3.1)
24
- actionview (= 6.1.3.1)
25
- activejob (= 6.1.3.1)
26
- activesupport (= 6.1.3.1)
22
+ actionmailer (6.1.3.2)
23
+ actionpack (= 6.1.3.2)
24
+ actionview (= 6.1.3.2)
25
+ activejob (= 6.1.3.2)
26
+ activesupport (= 6.1.3.2)
27
27
  mail (~> 2.5, >= 2.5.4)
28
28
  rails-dom-testing (~> 2.0)
29
- actionpack (6.1.3.1)
30
- actionview (= 6.1.3.1)
31
- activesupport (= 6.1.3.1)
29
+ actionpack (6.1.3.2)
30
+ actionview (= 6.1.3.2)
31
+ activesupport (= 6.1.3.2)
32
32
  rack (~> 2.0, >= 2.0.9)
33
33
  rack-test (>= 0.6.3)
34
34
  rails-dom-testing (~> 2.0)
35
35
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
- actiontext (6.1.3.1)
37
- actionpack (= 6.1.3.1)
38
- activerecord (= 6.1.3.1)
39
- activestorage (= 6.1.3.1)
40
- activesupport (= 6.1.3.1)
36
+ actiontext (6.1.3.2)
37
+ actionpack (= 6.1.3.2)
38
+ activerecord (= 6.1.3.2)
39
+ activestorage (= 6.1.3.2)
40
+ activesupport (= 6.1.3.2)
41
41
  nokogiri (>= 1.8.5)
42
- actionview (6.1.3.1)
43
- activesupport (= 6.1.3.1)
42
+ actionview (6.1.3.2)
43
+ activesupport (= 6.1.3.2)
44
44
  builder (~> 3.1)
45
45
  erubi (~> 1.4)
46
46
  rails-dom-testing (~> 2.0)
47
47
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
- activejob (6.1.3.1)
49
- activesupport (= 6.1.3.1)
48
+ activejob (6.1.3.2)
49
+ activesupport (= 6.1.3.2)
50
50
  globalid (>= 0.3.6)
51
- activemodel (6.1.3.1)
52
- activesupport (= 6.1.3.1)
53
- activerecord (6.1.3.1)
54
- activemodel (= 6.1.3.1)
55
- activesupport (= 6.1.3.1)
56
- activestorage (6.1.3.1)
57
- actionpack (= 6.1.3.1)
58
- activejob (= 6.1.3.1)
59
- activerecord (= 6.1.3.1)
60
- activesupport (= 6.1.3.1)
51
+ activemodel (6.1.3.2)
52
+ activesupport (= 6.1.3.2)
53
+ activerecord (6.1.3.2)
54
+ activemodel (= 6.1.3.2)
55
+ activesupport (= 6.1.3.2)
56
+ activestorage (6.1.3.2)
57
+ actionpack (= 6.1.3.2)
58
+ activejob (= 6.1.3.2)
59
+ activerecord (= 6.1.3.2)
60
+ activesupport (= 6.1.3.2)
61
61
  marcel (~> 1.0.0)
62
62
  mini_mime (~> 1.0.2)
63
- activesupport (6.1.3.1)
63
+ activesupport (6.1.3.2)
64
64
  concurrent-ruby (~> 1.0, >= 1.0.2)
65
65
  i18n (>= 1.6, < 2)
66
66
  minitest (>= 5.1)
@@ -69,7 +69,7 @@ GEM
69
69
  addressable (2.7.0)
70
70
  public_suffix (>= 2.0.2, < 5.0)
71
71
  ast (2.4.2)
72
- bootsnap (1.7.3)
72
+ bootsnap (1.7.5)
73
73
  msgpack (~> 1.0)
74
74
  builder (3.2.4)
75
75
  capybara (3.35.3)
@@ -82,20 +82,20 @@ GEM
82
82
  xpath (~> 3.2)
83
83
  childprocess (3.0.0)
84
84
  coderay (1.1.3)
85
- concurrent-ruby (1.1.8)
85
+ concurrent-ruby (1.1.9)
86
86
  crass (1.0.6)
87
87
  diff-lcs (1.4.4)
88
88
  erubi (1.10.0)
89
- factory_bot (6.1.0)
89
+ factory_bot (6.2.0)
90
90
  activesupport (>= 5.0.0)
91
- factory_bot_rails (6.1.0)
92
- factory_bot (~> 6.1.0)
91
+ factory_bot_rails (6.2.0)
92
+ factory_bot (~> 6.2.0)
93
93
  railties (>= 5.0.0)
94
94
  globalid (0.4.2)
95
95
  activesupport (>= 4.2.0)
96
96
  i18n (1.8.10)
97
97
  concurrent-ruby (~> 1.0)
98
- loofah (2.9.1)
98
+ loofah (2.10.0)
99
99
  crass (~> 1.0.2)
100
100
  nokogiri (>= 1.5.9)
101
101
  mail (2.7.1)
@@ -103,16 +103,16 @@ GEM
103
103
  marcel (1.0.1)
104
104
  method_source (1.0.0)
105
105
  mini_mime (1.0.3)
106
- mini_portile2 (2.5.0)
106
+ mini_portile2 (2.5.3)
107
107
  minitest (5.14.4)
108
108
  msgpack (1.4.2)
109
109
  nio4r (2.5.7)
110
- nokogiri (1.11.3)
110
+ nokogiri (1.11.7)
111
111
  mini_portile2 (~> 2.5.0)
112
112
  racc (~> 1.4)
113
113
  noncommittal (0.2.0)
114
114
  parallel (1.20.1)
115
- parser (3.0.1.0)
115
+ parser (3.0.1.1)
116
116
  ast (~> 2.4.1)
117
117
  pg (1.2.3)
118
118
  pry (0.14.1)
@@ -121,35 +121,35 @@ GEM
121
121
  pry-rails (0.3.9)
122
122
  pry (>= 0.10.4)
123
123
  public_suffix (4.0.6)
124
- puma (5.2.2)
124
+ puma (5.3.2)
125
125
  nio4r (~> 2.0)
126
126
  racc (1.5.2)
127
127
  rack (2.2.3)
128
128
  rack-test (1.1.0)
129
129
  rack (>= 1.0, < 3)
130
- rails (6.1.3.1)
131
- actioncable (= 6.1.3.1)
132
- actionmailbox (= 6.1.3.1)
133
- actionmailer (= 6.1.3.1)
134
- actionpack (= 6.1.3.1)
135
- actiontext (= 6.1.3.1)
136
- actionview (= 6.1.3.1)
137
- activejob (= 6.1.3.1)
138
- activemodel (= 6.1.3.1)
139
- activerecord (= 6.1.3.1)
140
- activestorage (= 6.1.3.1)
141
- activesupport (= 6.1.3.1)
130
+ rails (6.1.3.2)
131
+ actioncable (= 6.1.3.2)
132
+ actionmailbox (= 6.1.3.2)
133
+ actionmailer (= 6.1.3.2)
134
+ actionpack (= 6.1.3.2)
135
+ actiontext (= 6.1.3.2)
136
+ actionview (= 6.1.3.2)
137
+ activejob (= 6.1.3.2)
138
+ activemodel (= 6.1.3.2)
139
+ activerecord (= 6.1.3.2)
140
+ activestorage (= 6.1.3.2)
141
+ activesupport (= 6.1.3.2)
142
142
  bundler (>= 1.15.0)
143
- railties (= 6.1.3.1)
143
+ railties (= 6.1.3.2)
144
144
  sprockets-rails (>= 2.0.0)
145
145
  rails-dom-testing (2.0.3)
146
146
  activesupport (>= 4.2.0)
147
147
  nokogiri (>= 1.6)
148
148
  rails-html-sanitizer (1.3.0)
149
149
  loofah (~> 2.3)
150
- railties (6.1.3.1)
151
- actionpack (= 6.1.3.1)
152
- activesupport (= 6.1.3.1)
150
+ railties (6.1.3.2)
151
+ actionpack (= 6.1.3.2)
152
+ activesupport (= 6.1.3.2)
153
153
  method_source
154
154
  rake (>= 0.8.7)
155
155
  thor (~> 1.0)
@@ -174,19 +174,19 @@ GEM
174
174
  rspec-mocks (~> 3.10)
175
175
  rspec-support (~> 3.10)
176
176
  rspec-support (3.10.2)
177
- rubocop (1.12.1)
177
+ rubocop (1.14.0)
178
178
  parallel (~> 1.10)
179
179
  parser (>= 3.0.0.0)
180
180
  rainbow (>= 2.2.2, < 4.0)
181
181
  regexp_parser (>= 1.8, < 3.0)
182
182
  rexml
183
- rubocop-ast (>= 1.2.0, < 2.0)
183
+ rubocop-ast (>= 1.5.0, < 2.0)
184
184
  ruby-progressbar (~> 1.7)
185
185
  unicode-display_width (>= 1.4.0, < 3.0)
186
- rubocop-ast (1.4.1)
187
- parser (>= 2.7.1.5)
188
- rubocop-performance (1.10.1)
189
- rubocop (>= 0.90.0, < 2.0)
186
+ rubocop-ast (1.7.0)
187
+ parser (>= 3.0.1.1)
188
+ rubocop-performance (1.11.2)
189
+ rubocop (>= 1.7.0, < 2.0)
190
190
  rubocop-ast (>= 0.4.0)
191
191
  ruby-progressbar (1.11.0)
192
192
  rubyzip (2.3.0)
@@ -200,9 +200,9 @@ GEM
200
200
  actionpack (>= 4.0)
201
201
  activesupport (>= 4.0)
202
202
  sprockets (>= 3.0.0)
203
- standard (1.0.5)
204
- rubocop (= 1.12.1)
205
- rubocop-performance (= 1.10.1)
203
+ standard (1.1.1)
204
+ rubocop (= 1.14.0)
205
+ rubocop-performance (= 1.11.2)
206
206
  thor (1.1.0)
207
207
  tzinfo (2.0.4)
208
208
  concurrent-ruby (~> 1.0)
@@ -211,7 +211,7 @@ GEM
211
211
  nokogiri (~> 1.6)
212
212
  rubyzip (>= 1.3.0)
213
213
  selenium-webdriver (>= 3.0, < 4.0)
214
- websocket-driver (0.7.3)
214
+ websocket-driver (0.7.5)
215
215
  websocket-extensions (>= 0.1.0)
216
216
  websocket-extensions (0.1.5)
217
217
  xpath (3.2.0)
@@ -24,6 +24,9 @@ module Example
24
24
  # Initialize configuration defaults for originally generated Rails version.
25
25
  config.load_defaults 6.1
26
26
 
27
+ # Uncomment this to switch from schema.rb to structure.sql
28
+ # config.active_record.schema_format = :sql
29
+
27
30
  # Configuration for the application, engines, and railties goes here.
28
31
  #
29
32
  # These settings can be overridden in specific environments using the files
@@ -1,2 +1 @@
1
- F/lkjSeOZwy+4IAYNV/+5sOwn9XOGjyNNvDkNyrpRG0kqoP8jmI4GE8mb73fdRIVoI9H7zefa3GxQ7R+udxqKWMLwAtSgTt+YGf5Eng0IzRBPp7hY2gIxFO0b84/+eG4Q6rD5xsg0kogzK3Ab4jj7f8Ci8vzFclSwqyUwP6TBCnaZJYsLMcNmF3tKBnWrJNKcQJ6Rj6/J2OH/nNi5x+KbsIgbARCJsZEK8PjD+cx8Qs9Cvk99Pj3VljLmjYA0L3jx1uCKahr0tzkkPkujBCKci05QHF/+vq0fcFduxc5wwlf5qMf7wGayz8i1YONyM9yORMrcnvSz/6AKC25np24+nmvZNsuVqtyoA4LRL+k3RBCMKo867FkwJmmGkhZSAFplFdQ2C0qJ+Gzem6UD6Lr70klDaUq1hITDqIc--nPRVkeqxjYlJDoKQ--Iu4hCDiJSpYuKL56Z/CUjA==
2
-
1
+ 5AstMrUHKXO5ed+i/hI/GnVm5IB525qXJOqPHvqfqhJSxEJSyfwKfQURigix3HsTcOwcPFIU6vPSC20bi5H8CQ7SHnYdHJuGB2T3WC9iiNiSBz49HaZoYX8ucHYoMMBbC+0u/6diYLW8ZTKR2Ab7bn4r1lkGzQjJe5clic5wNto7btjAbStXyAOHZCStXfnOFgQQhVjZno3iS7c279jaVYkYpZ12P5LbMxcJO4ipWfFexCzysIQu/WSPfmNMcvrIPijmPBvkVMJuhhDzd0yk1ysJu8jJMa8FJKx9aVd7Bes/k8Nywd04GDY6eSxyH6gkoG+BeQeqW3ig1XsuOWvx39qE9EQAcsgT13uxGc8M4wBKqIdSoibPl/79kTB843rnGlL8X/pKipJYczYJxazLSojwcQSto1UeIqQFWaDPQhz0--C7YAj7j4YQdWGiMG--JFTyHZbGKXiCdfZoBmF3xw==
@@ -32,7 +32,7 @@ rescue ActiveRecord::PendingMigrationError => e
32
32
  end
33
33
  RSpec.configure do |config|
34
34
  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
35
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
35
+ config.fixture_path = "#{::Rails.root}/test/fixtures"
36
36
 
37
37
  # If you're not using ActiveRecord, or you'd prefer not to run each of your
38
38
  # examples within a transaction, remove the following line or assign false
@@ -2,11 +2,7 @@ require "rails_helper"
2
2
 
3
3
  RSpec.configure do |config|
4
4
  config.before(:each) do
5
- TestData.load
6
- end
7
-
8
- config.after(:each) do
9
- TestData.rollback
5
+ TestData.uses_test_data
10
6
  end
11
7
  end
12
8
 
@@ -0,0 +1,106 @@
1
+ require "rails_helper"
2
+
3
+ TestData.prevent_rails_fixtures_from_loading_automatically!
4
+
5
+ module TestDataModes
6
+ def uses(mode)
7
+ case mode
8
+ when :clean_slate
9
+ before(:each) { TestData.uses_clean_slate }
10
+ when :test_data
11
+ before(:each) { TestData.uses_test_data }
12
+ else
13
+ raise "Invalid test data mode: #{mode}"
14
+ end
15
+ end
16
+ end
17
+
18
+ RSpec.configure do |config|
19
+ config.extend(TestDataModes)
20
+ end
21
+
22
+ RSpec.describe "FixtureFreeTestData", type: :request do
23
+ fixtures :boops
24
+
25
+ uses :test_data
26
+ it "has 15 boops in the test_data" do
27
+ expect(Boop.count).to eq(15)
28
+ end
29
+ end
30
+
31
+ RSpec.describe "Clean Slate" do
32
+ uses :clean_slate
33
+
34
+ it "has no boops" do
35
+ expect(Boop.count).to eq(0)
36
+ end
37
+ end
38
+
39
+ RSpec.describe "FixturesUsingTest", type: :request do
40
+ fixtures :boops
41
+
42
+ before(:each) do
43
+ TestData.uses_rails_fixtures(self)
44
+ end
45
+
46
+ it "has_fixture_boops" do
47
+ expect(boops(:boop_1)).to be_persisted
48
+ expect(Boop.count).to eq(2)
49
+ end
50
+
51
+ it "does_not_get_the_other_fixture_accessor" do
52
+ expect { method(:pants) }.to raise_error(NameError)
53
+ end
54
+
55
+ it "even_explicitly_loading_test_data_will_truncate_and_then_load_fixtures" do
56
+ TestData.uses_test_data
57
+ TestData.uses_rails_fixtures(self)
58
+
59
+ expect(Boop.count).to eq(2)
60
+ end
61
+
62
+ it "load_and_rollback_leaves_them_as_is" do
63
+ boop = Boop.first
64
+ original_created_on = boop.created_at.to_date
65
+ a_year_ago = 1.year.ago.to_date
66
+
67
+ boop.update!(created_at: a_year_ago)
68
+
69
+ expect(Boop.find(boop.id).created_at.to_date).to eq(a_year_ago)
70
+
71
+ # Now after rollback
72
+ TestData.uses_rails_fixtures(self)
73
+
74
+ expect(Boop.find(boop.id).created_at.to_date).to eq(original_created_on)
75
+ end
76
+ end
77
+
78
+ RSpec.describe "SomeFixturesAndSomeTestDataInOneClassTest", type: :request do
79
+ fixtures :all
80
+
81
+ it "fixtures_work" do
82
+ TestData.uses_rails_fixtures(self)
83
+
84
+ expect(boops(:boop_1).updated_at.to_date).to eq(Date.civil(2020, 1, 1))
85
+ expect(pants(:pant_1).brand).to eq("Levi")
86
+ end
87
+
88
+ it "test_that_rewinds_to_test_data" do
89
+ TestData.uses_test_data
90
+
91
+ expect(Boop.count).to eq(15)
92
+ end
93
+
94
+ it "that_rewinds_to_the_very_start" do
95
+ TestData.uninitialize
96
+
97
+ expect(Boop.count).to eq(0)
98
+ end
99
+
100
+ it "fixtures_get_reloaded_because_cache_is_cleared" do
101
+ TestData.uses_rails_fixtures(self)
102
+
103
+ expect(boops(:boop_2).updated_at.to_date).to eq(Date.civil(2019, 1, 1))
104
+ expect(pants(:pant_2).brand).to eq("Wrangler")
105
+ end
106
+ end
@@ -8,19 +8,11 @@ class ActiveSupport::TestCase
8
8
  include FactoryBot::Syntax::Methods
9
9
 
10
10
  setup do
11
- TestData.truncate
12
- end
13
-
14
- teardown do
15
- TestData.rollback(:after_data_truncate)
11
+ TestData.uses_clean_slate
16
12
  end
17
13
  when :test_data
18
14
  setup do
19
- TestData.load
20
- end
21
-
22
- teardown do
23
- TestData.rollback
15
+ TestData.uses_test_data
24
16
  end
25
17
  end
26
18
  end
@@ -42,4 +34,8 @@ class SomeTestDataUsingTest < ActionDispatch::IntegrationTest
42
34
  def test_boops
43
35
  assert_equal 10, Boop.count
44
36
  end
37
+
38
+ def test_factory_bot_method_is_not_on_this_class
39
+ assert_raises(NameError) { method(:create) }
40
+ end
45
41
  end
@@ -0,0 +1,82 @@
1
+ # Regression test to make sure we don't load fixtures too many times
2
+
3
+ class HookCounter
4
+ def self.count
5
+ @call_count || 0
6
+ end
7
+
8
+ def self.count!
9
+ @call_count ||= 0
10
+ @call_count += 1
11
+ end
12
+ end
13
+ at_exit do
14
+ if TestData.statistics.load_rails_fixtures_count > 2 # could be 1 if :all runs first, 2 if :boops only does
15
+ raise "Rails fixture load was called #{TestData.statistics.load_rails_fixtures_count} times, shouldn't be more than 2!"
16
+ end
17
+ if HookCounter.count > 2
18
+ raise "Rails fixture load hook was called #{HookCounter.count} times, shouldn't be more than 2!"
19
+ end
20
+ end
21
+
22
+ require "test_helper"
23
+
24
+ TestData.prevent_rails_fixtures_from_loading_automatically!
25
+
26
+ TestData.config do |config|
27
+ config.after_rails_fixture_load {
28
+ HookCounter.count!
29
+ }
30
+ end
31
+
32
+ class PartialFixtureTest < ActiveSupport::TestCase
33
+ fixtures :boops
34
+
35
+ setup do
36
+ TestData.uses_rails_fixtures(self)
37
+ end
38
+
39
+ def test_has_only_boops
40
+ assert boops(:boop_1)
41
+ assert_raises(NameError) { method(:pants) }
42
+ end
43
+ end
44
+
45
+ class AllFixtureTest < ActiveSupport::TestCase
46
+ fixtures :all
47
+
48
+ setup do
49
+ TestData.uses_rails_fixtures(self)
50
+ end
51
+
52
+ def test_has_both
53
+ assert boops(:boop_1)
54
+ assert pants(:pant_1)
55
+ end
56
+ end
57
+
58
+ class AllFixtureTest2 < ActiveSupport::TestCase
59
+ fixtures :all
60
+
61
+ setup do
62
+ TestData.uses_rails_fixtures(self)
63
+ end
64
+
65
+ def test_has_both
66
+ assert boops(:boop_1)
67
+ assert pants(:pant_1)
68
+ end
69
+ end
70
+
71
+ class AllFixtureTest3 < ActiveSupport::TestCase
72
+ fixtures :all
73
+
74
+ setup do
75
+ TestData.uses_rails_fixtures(self)
76
+ end
77
+
78
+ def test_has_both
79
+ assert boops(:boop_1)
80
+ assert pants(:pant_1)
81
+ end
82
+ end