From 8bb25f3ac70bbc7fbd4aa1636ea34306d0c53953 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 18 Mar 2018 21:20:35 +0000 Subject: [PATCH] Fix tests --- test/configuration_test.rb | 12 ++++++------ test/dev_server_test.rb | 4 ---- test/env_test.rb | 3 --- test/test_helper.rb | 4 ++++ 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/test/configuration_test.rb b/test/configuration_test.rb index 2901a1905..f3bc08b20 100644 --- a/test/configuration_test.rb +++ b/test/configuration_test.rb @@ -42,29 +42,29 @@ def test_extensions def test_cache_manifest? with_rails_env("development") do - refute reloaded_config.cache_manifest? + refute Webpacker.config.cache_manifest? end with_rails_env("test") do - refute reloaded_config.cache_manifest? + refute Webpacker.config.cache_manifest? end with_rails_env("production") do - assert reloaded_config.cache_manifest? + assert Webpacker.config.cache_manifest? end end def test_compile? with_rails_env("development") do - assert reloaded_config.compile? + assert Webpacker.config.compile? end with_rails_env("test") do - assert reloaded_config.compile? + assert Webpacker.config.compile? end with_rails_env("production") do - refute reloaded_config.compile? + refute Webpacker.config.compile? end end end diff --git a/test/dev_server_test.rb b/test/dev_server_test.rb index 568e2c354..79ba0c9ab 100644 --- a/test/dev_server_test.rb +++ b/test/dev_server_test.rb @@ -3,28 +3,24 @@ class DevServerTest < Webpacker::Test def test_running? with_rails_env("production") do - reloaded_config refute Webpacker.dev_server.running? end end def test_host with_rails_env("development") do - reloaded_config assert_equal Webpacker.dev_server.host, "localhost" end end def test_port with_rails_env("development") do - reloaded_config assert_equal Webpacker.dev_server.port, 3035 end end def test_https? with_rails_env("development") do - reloaded_config assert_equal Webpacker.dev_server.https?, false end end diff --git a/test/env_test.rb b/test/env_test.rb index ae175dae2..efb6a3c18 100644 --- a/test/env_test.rb +++ b/test/env_test.rb @@ -2,20 +2,17 @@ class EnvTest < Webpacker::Test def test_current - reloaded_config assert_equal Webpacker.env, Rails.env end def test_custom_without_config with_rails_env("foo") do - reloaded_config assert_equal Webpacker.env, "production" end end def test_custom_with_config with_rails_env("staging") do - reloaded_config assert_equal Webpacker.env, "staging" end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 6bf0d40d3..030b77e68 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -6,6 +6,8 @@ require_relative "test_app/config/environment" +Rails.env = "production" + Webpacker.instance = Webpacker::Instance.new \ root_path: Pathname.new(File.expand_path("test_app", __dir__)), config_path: Pathname.new(File.expand_path("./test_app/config/webpacker.yml", __dir__)) @@ -22,8 +24,10 @@ def reloaded_config def with_rails_env(env) original = Rails.env Rails.env = ActiveSupport::StringInquirer.new(env) + reloaded_config yield ensure Rails.env = ActiveSupport::StringInquirer.new(original) + reloaded_config end end