`rake jasmine:ci` 适用于 c9,但 运行 rake jasmine 与端口和 IP 问题冲突

`rake jasmine:ci` works on c9, but running rake jasmine falls foul of port and IP issues

rake jasmine:ci 在 c9 上工作,但 运行 rake jasmine 似乎不工作(在端点上看不到任何东西),即使配置调整如下:

Jasmine.configure do |config|
  config.server_port = ENV['PORT']
  config.host = "http://#{ENV['IP']}"
end

(我也试过config.host = ENV['IP'])

c9 不再抱怨我们在错误的端口和 IP 上更新了配置,但是在 c9 端点没有应用 运行 并且 rake jasmine 的输出看起来是正确的:

tansaku@saasbook-ruby:~/workspace/myrottenpotatoes (master) $ rake jasmine
your server is running here: http://localhost:8080/
your tests are here:         /home/ubuntu/workspace/myrottenpotatoes/spec/javascripts
your source files are here:  /home/ubuntu/workspace/myrottenpotatoes

[2015-08-10 02:41:06] INFO  WEBrick 1.3.1
[2015-08-10 02:41:06] INFO  ruby 2.2.1 (2015-02-26) [x86_64-linux]
[2015-08-10 02:41:06] INFO  WEBrick::HTTPServer#start: pid=7713 port=8080

(我得到 "No application seems to be running here!")相反,同一实例中的 rails 应用程序工作正常...

我想知道 jasmine 在呈现阻止 c9 端点工作的端点方面是否做了什么;虽然我不能立即明白为什么它不会因为 c9 被设置为同时服务 rails 和 ruby 应用程序...

您的服务器应该 运行 位于 0.0.0.0:8080 才能从外部访问。我不确定为什么用 ENV["IP"] 覆盖 config.host 仍然会给你 'http://localhost' 因为你终端上的 运行 echo $IP 应该给出结果 0.0.0.0 而不是在托管的 Cloud9 工作区上。请使用 config.host = "http://0.0.0.0"config.host = "0.0.0.0" 再试一次以确保安全。

啊,找到解决办法了。我们需要在 jasmine.yml 中设置机架选项:

rack_options:
  Host: '0.0.0.0'

现在可以了