File tree Expand file tree Collapse file tree 4 files changed +27
-18
lines changed Expand file tree Collapse file tree 4 files changed +27
-18
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ namespace :webpacker do
7
7
required_node_version = "6.4"
8
8
9
9
raise Errno ::ENOENT if node_version . blank?
10
+
10
11
if Gem ::Version . new ( node_version . strip . tr ( "v" , "" ) ) < Gem ::Version . new ( required_node_version )
11
12
$stderr. puts "Webpacker requires Node.js >= v#{ required_node_version } and you are using #{ node_version } "
12
13
$stderr. puts "Please upgrade Node.js https://nodejs.org/en/download/"
Original file line number Diff line number Diff line change 1
1
require "webpacker_test_helper"
2
2
3
- class ConfigurationTest < Minitest ::Test
3
+ class ConfigurationTest < Webpacker ::Test
4
4
def test_source_path
5
5
source_path = File . expand_path File . join ( File . dirname ( __FILE__ ) , "test_app/app/javascript" ) . to_s
6
6
assert_equal source_path , Webpacker . config . source_path . to_s
@@ -39,18 +39,4 @@ def test_compile?
39
39
refute reloaded_config . compile?
40
40
end
41
41
end
42
-
43
- private
44
- def with_node_env ( env )
45
- original = ENV [ "NODE_ENV" ]
46
- ENV [ "NODE_ENV" ] = env
47
- yield
48
- ensure
49
- ENV [ "NODE_ENV" ] = original
50
- end
51
-
52
- def reloaded_config
53
- Webpacker . instance . instance_variable_set ( :@config , nil )
54
- Webpacker . config
55
- end
56
42
end
Original file line number Diff line number Diff line change 1
1
require "webpacker_test_helper"
2
2
3
- class DevServerTest < Minitest ::Test
3
+ class DevServerTest < Webpacker ::Test
4
4
def test_host
5
- assert_equal "localhost" , Webpacker . dev_server . host
5
+ with_node_env ( "development" ) do
6
+ reloaded_config
7
+ assert_equal Webpacker . dev_server . host , "localhost"
8
+ end
6
9
end
7
10
8
11
def test_port
9
- assert_equal Webpacker . dev_server . port , 3035
12
+ with_node_env ( "development" ) do
13
+ reloaded_config
14
+ assert_equal Webpacker . dev_server . port , 3035
15
+ end
10
16
end
11
17
end
Original file line number Diff line number Diff line change @@ -20,5 +20,21 @@ class Application < ::Rails::Application
20
20
end
21
21
end
22
22
23
+ class Webpacker ::Test < Minitest ::Test
24
+ private
25
+ def reloaded_config
26
+ Webpacker . instance . instance_variable_set ( :@config , nil )
27
+ Webpacker . config
28
+ end
29
+
30
+ def with_node_env ( env )
31
+ original = ENV [ "NODE_ENV" ]
32
+ ENV [ "NODE_ENV" ] = env
33
+ yield
34
+ ensure
35
+ ENV [ "NODE_ENV" ] = original
36
+ end
37
+ end
38
+
23
39
Rails . backtrace_cleaner . remove_silencers!
24
40
TestApp ::Application . initialize!
You can’t perform that action at this time.
0 commit comments