Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravtiwari committed Mar 18, 2018
1 parent c0d28df commit 8bb25f3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
12 changes: 6 additions & 6 deletions test/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 0 additions & 4 deletions test/dev_server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions test/env_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand All @@ -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

0 comments on commit 8bb25f3

Please sign in to comment.