Skip to content

Commit

Permalink
Test config.compile? in all envs
Browse files Browse the repository at this point in the history
  • Loading branch information
javan committed Aug 12, 2017
1 parent 604ee8e commit acd81f5
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion test/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@ def test_cache_path
end

def test_compile?
assert Webpacker.config.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

private
def with_node_env(env)
original = ENV["NODE_ENV"]
ENV["NODE_ENV"] = env
yield
ensure
ENV["NODE_ENV"] = original
end

def reloaded_config
Webpacker.instance.instance_variable_set(:@config, nil)
Webpacker.config
end
end

0 comments on commit acd81f5

Please sign in to comment.