test/configuration_test.rb in webpacker-2.0 vs test/configuration_test.rb in webpacker-3.0.0

- old
+ new

@@ -1,32 +1,56 @@ -require "webpacker_test" +require "webpacker_test_helper" -class ConfigurationTest < Minitest::Test - def test_entry_path - entry_path = File.join(File.dirname(__FILE__), "test_app/app/javascript", "packs").to_s - assert_equal Webpacker::Configuration.entry_path.to_s, entry_path +class ConfigurationTest < Webpacker::Test + def test_source_path + source_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/app/javascript").to_s + assert_equal source_path, Webpacker.config.source_path.to_s end - def test_file_path - file_path = File.join(File.dirname(__FILE__), "test_app/config", "webpacker.yml").to_s - assert_equal Webpacker::Configuration.file_path.to_s, file_path + def test_source_entry_path + source_entry_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/app/javascript", "packs").to_s + assert_equal Webpacker.config.source_entry_path.to_s, source_entry_path end - def test_manifest_path - manifest_path = File.join(File.dirname(__FILE__), "test_app/public/packs", "manifest.json").to_s - assert_equal Webpacker::Configuration.manifest_path.to_s, manifest_path + def test_public_output_path + public_output_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/public/packs").to_s + assert_equal Webpacker.config.public_output_path.to_s, public_output_path end - def test_output_path - output_path = File.join(File.dirname(__FILE__), "test_app/public/packs").to_s - assert_equal Webpacker::Configuration.output_path.to_s, output_path + def test_public_manifest_path + public_manifest_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/public/packs", "manifest.json").to_s + assert_equal Webpacker.config.public_manifest_path.to_s, public_manifest_path end - def test_source - assert_equal Webpacker::Configuration.source.to_s, "app/javascript" + def test_cache_path + cache_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/tmp/cache/webpacker").to_s + assert_equal Webpacker.config.cache_path.to_s, cache_path end - def test_source_path - source_path = File.join(File.dirname(__FILE__), "test_app/app/javascript").to_s - assert_equal Webpacker::Configuration.source_path.to_s, source_path + def test_cache_manifest? + with_node_env("development") do + refute reloaded_config.cache_manifest? + end + + with_node_env("test") do + refute reloaded_config.cache_manifest? + end + + with_node_env("production") do + assert reloaded_config.cache_manifest? + end + end + + def test_compile? + with_node_env("development") do + assert reloaded_config.compile? + end + + with_node_env("test") do + assert reloaded_config.compile? + end + + with_node_env("production") do + refute reloaded_config.compile? + end end end