由于405 API响应,量角器测试在Codeship上失败

时间:2015-05-21 12:43:04

标签: ruby-on-rails ajax protractor http-status-code-405 codeship

量角器配置和脚本在我们的本地开发环境和持续集成环境(类似于Codeship)中按预期工作。

项目结构如下(我在下面描述了Codeship env。状态):

AngularJS 应用使用 AJAX ,使用 Ruby on rails 应用从 REST API 构建请求数据请求。

在我们的Codeship配置中,我们设置了rails app,迁移和播种数据库,以便获得所有必要的数据。

AngularJS应用程序也已正确配置,因为登录页面按预期呈现(我正在打印屏幕,主页面已正确加载)。

用户名和密码由量角器使用有效凭证填写(在mysql数据库中可用)。

但是当点击“登录”时按钮来自AJAX调用的返回响应是405方法不允许

由于我们在其他环境中从未遇到此响应,因此我们认为它与特定的代码设置有关。

有任何想法为什么API只会在Codeship上返回405?

设置如下:

rvm use 2.2.0 --install
cp config/database.codeship.yml config/database.yml
bundle install
export RAILS_ENV="test"
bundle exec rake db:drop RAILS_ENV=test
bundle exec rake db:create RAILS_ENV=test
bundle exec rake db:test:prepare
bundle exec rake db:migrate RAILS_ENV=test
bundle exec rake seed:migrate RAILS_ENV=test
cd frontend && npm install && cd ..
npm install -g grunt-cli
npm install -g http-server
cd frontend && npm install bower && cd ..
cd frontend && bower install && cd ..
cd frontend && grunt build && cd ..
cd frontend && webdriver-manager update --standalone && cd ..
export RAILS_ENV="development"
rake db:structure:load
rake seed:migrate
http-server public -a 127.0.0.1 -p 9000 > /dev/null &
http-server app > /dev/null &
bundle exec rake
cd frontend && grunt test && cd ..

以下是显示API响应的屏幕截图部分: enter image description here

1 个答案:

答案 0 :(得分:0)

最后,我们的解决方案是使用protractor-rails - 基本上使用rails服务器的基本URL而不是尝试通过grunt在不同的URL上运行应用程序。我们的设置现在看起来像这样:

rvm use 2.2.0 --install
cp config/database.codeship.yml config/database.yml
bundle install
# protractor tests
export RAILS_ENV="development"
rake db:structure:load
rake seed:migrate
npm install
webdriver-manager update
bundle exec rake protractor:init RAILS_ENV=development
bundle exec rake protractor:spec RAILS_ENV=development
# rails tests
bundle exec rake db:test:prepare
bundle exec rake db:migrate RAILS_ENV=test
bundle exec rake seed:migrate RAILS_ENV=test
bundle exec rake