docbrown/spec/initializers/application_config_spec.rb
Dmitry Maksyoma be07697d6d
Adapt dev env to run on a remote box (#8232)
* Adapt dev env to run on a remote box

* webpack-dev-server ignores CLI arguments, so switched to environment
  variables.
* Dynamically determine remote webpack host via APP_DOMAIN environment
  variable, defined in application.yml.
* Setup content security policy to allow connecting to webpack on a
  remote box, defined by APP_DOMAIN environment variable.

* Make Webpacker listen on 0.0.0.0

* Account for APP_DOMAIN port

* Add support for URI scheme and tests

* Fix a spec by disabling a Rubocop linter
2020-06-18 13:01:49 +02:00

39 lines
1,017 B
Ruby

require "rails_helper"
describe ApplicationConfig do
describe ".app_domain_no_port" do
it "handles plain subdomain only name" do
setup_app_domain("renner")
expect(described_class.app_domain_no_port).to eq "renner"
end
it "handles plain domain name" do
setup_app_domain("renner.ngrok.io")
expect(described_class.app_domain_no_port).to eq "renner.ngrok.io"
end
it "handles domain with port" do
setup_app_domain("renner:3000")
expect(described_class.app_domain_no_port).to eq "renner"
end
it "handles domain with schema and port" do
setup_app_domain("http://renner:4000")
expect(described_class.app_domain_no_port).to eq "renner"
end
private
def setup_app_domain(app_domain)
# No #and_return for #have_received.
# rubocop:disable RSpec/MessageSpies
expect(ApplicationConfig).to receive(:[]).with("APP_DOMAIN").
and_return(app_domain)
# rubocop:enable RSpec/MessageSpies
end
end
end