Sha256: d93804b5c239e8a2855abcaf9955a42fd0c82f54b1bc06f7bf7c4c83789b471a

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

require "webpacker_test"

class DevServerTest < Minitest::Test
  require "webpacker_test"

  def check_assertion
    stub_value = ActiveSupport::StringInquirer.new("development")
    Webpacker.stub(:env, stub_value) do
      Webpacker::Configuration.reset
      Webpacker::DevServer.reset
      result = yield
      assert_equal(result[0], result[1])
    end
    Webpacker::Configuration.reset
    Webpacker::DevServer.reset
  end

  def test_dev_server?
    check_assertion { [true, Webpacker::DevServer.dev_server?] }
  end

  def test_dev_server_host
    check_assertion { ["localhost", Webpacker::DevServer.host] }
  end

  def test_dev_server_port
    check_assertion { [8080, Webpacker::DevServer.port] }
  end

  def test_dev_server_hot?
    check_assertion { [false, Webpacker::DevServer.hot?] }

    ENV.stub(:[], "TRUE") do
      check_assertion { [true, Webpacker::DevServer.hot?] }
    end

    ENV.stub(:[], "FALSE") do
      check_assertion { [false, Webpacker::DevServer.hot?] }
    end
    ENV.stub(:[], "true") do
      check_assertion { [true, Webpacker::DevServer.hot?] }
    end
  end

  def test_dev_server_https?
    check_assertion { [false, Webpacker::DevServer.https?] }
  end

  def test_dev_server_protocol?
    check_assertion { ["http", Webpacker::DevServer.protocol] }
  end

  def test_base_url?
    check_assertion { ["http://localhost:8080", Webpacker::DevServer.base_url] }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
webpacker-react-on-rails-3.0.0.rc.1 test/dev_server_test.rb
webpacker-react-on-rails-2.0 test/dev_server_test.rb