File tree 3 files changed +27
-19
lines changed 3 files changed +27
-19
lines changed Original file line number Diff line number Diff line change 1
1
require 'test_helper'
2
2
3
3
4
- when_webpacker_available do
4
+ WebpackerHelpers . when_webpacker_available do
5
5
class ReactRailsWebpackerTest < ActionDispatch ::IntegrationTest
6
6
include Capybara ::DSL
7
7
@@ -10,7 +10,7 @@ class ReactRailsWebpackerTest < ActionDispatch::IntegrationTest
10
10
end
11
11
12
12
teardown do
13
- clear_webpacker_packs
13
+ WebpackerHelpers . clear_webpacker_packs
14
14
end
15
15
16
16
test 'it mounts pages from the pack' do
Original file line number Diff line number Diff line change
1
+ module WebpackerHelpers
2
+ module_function
3
+
4
+ def when_webpacker_available
5
+ if defined? ( Webpacker )
6
+ clear_webpacker_packs
7
+ Dir . chdir ( "./test/dummy" ) do
8
+ Rake ::Task [ 'webpacker:compile' ] . invoke
9
+ end
10
+ # Reload cached JSON manifest:
11
+ Webpacker ::Manifest . load
12
+ yield
13
+ end
14
+ end
15
+
16
+ def clear_webpacker_packs
17
+ packs_directory = File . expand_path ( "../dummy/public/packs" , __FILE__ )
18
+ FileUtils . rm_rf ( packs_directory )
19
+ end
20
+ end
Original file line number Diff line number Diff line change 15
15
require "capybara/poltergeist"
16
16
Dummy ::Application . load_tasks
17
17
18
+ support_path = File . expand_path ( "../support/*.rb" , __FILE__ )
19
+ Dir . glob ( support_path ) . each do |f |
20
+ require ( f )
21
+ end
22
+
18
23
Capybara . javascript_driver = :poltergeist
19
24
Capybara . app = Rails . application
20
25
@@ -131,23 +136,6 @@ def when_sprockets_available
131
136
end
132
137
end
133
138
134
- def when_webpacker_available
135
- if defined? ( Webpacker )
136
- clear_webpacker_packs
137
- Dir . chdir ( "./test/dummy" ) do
138
- Rake ::Task [ 'webpacker:compile' ] . invoke
139
- end
140
- # Reload cached JSON manifest:
141
- Webpacker ::Manifest . load
142
- yield
143
- end
144
- end
145
-
146
- def clear_webpacker_packs
147
- packs_directory = File . expand_path ( "../dummy/public/packs" , __FILE__ )
148
- FileUtils . rm_rf ( packs_directory )
149
- end
150
-
151
139
def fetch_asset_body ( asset_logical_path )
152
140
Rails . application . assets [ asset_logical_path ] . to_s
153
141
end
You can’t perform that action at this time.
0 commit comments