量角器测试失败的codeship由于405 API响应量角器、测试、codeship、API

2023-09-10 21:57:48 作者:你的寶貝

如预期无论在我们的本地开发环境和持续集成环境(类似于codeship)。量角器配置和脚本工​​作

The protractor configuration and scripts work as expected both on our local development environment and in a continuous integration environment (similar to Codeship).

该项目结构如下(我所描述的codeship ENV状态下图):

The project structure is the following (I'm describing the Codeship env. status below):

在 AngularJS 应用请求的数据从 REST API 在轨道上建立一个与红宝石应用,使用的 AJAX 请求。

The AngularJS app requests data from the REST API build with the Ruby on rails app, using AJAX requests.

在我们的codeship配置,我们建立了Rails应用程序,迁移和种子数据库,以便所有必要的数据是可用的。

In our Codeship configuration we set up the rails app, migrate and seed the database so that all necessary data is available.

在AngularJS应用程序也被正确配置,因为在登录页呈现为预期(我正在做一个打印屏幕,而主页是否正确装入)。

The AngularJS app is also configured correctly since the login page is rendered as expected (I'm doing a print screen, and the main page is loaded correctly).

在USENAME和密码通过使用有效凭据(在MySQL数据库可用)量角器填写。

The usename and password are filled in by protractor using valid credentials (available in the mysql DB).

不过,点击登录按钮时的从AJAX调用返回的响应是405不允许的方法

But when clicking the 'Log In' button the returned response from the AJAX call is a 405 Method Not Allowed.

由于我们从来没有遇到过在我们的其他环境中这种反应,我们认为它是与特定的codeship设置。

As we never encountered this response in our other environments we believe it has something to do with the specific codeship setup.

任何思考为什么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响应的屏幕截图的一部分:

Here is the part of the screenshot that shows the API response:

推荐答案

在年底,我们的解决方案是使用的量角器护栏 - 基本上都采用导轨服务器,而不是试图通过咕噜运行在不同的URL应用程序的基本URL。我们的安装程序现在看起来是这样的:

In the end, the solution for us was to use protractor-rails - basically using the base url of the rails server instead of trying to run the app on a different URL through grunt. Our setup now looks like this:

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