ruby-on-rails - 无法使用 zeus 的 parallel_tests 创建并行数据库

标签 ruby-on-rails testing rspec zeus

我对 zeus-parallel_tests 和他的初始化有疑问:

我的 gem 文件:

group :development, :test do
  gem "sqlite3"
  gem "rspec-rails"
  gem "rspec-its"
  gem "guard-rspec"
  gem "quiet_assets"
  gem "dotenv-rails"
  gem "parallel_tests"
  gem "zeus-parallel_tests"
end

然后捆绑,好吧

我的 database.yml 配置:

connection: &connection
  adapter: postgresql
  host: localhost
  username: ********
  password: ********
  encoding: utf8
  min_messages: warning

development:
  database: app_development
  <<: *connection

test:
  database: app_test<%= ENV['TEST_ENV_NUMBER'] %>
  <<: *connection

production:
  database: app_production
  <<: *connection

然后 zeus-parallel_tests init 用于创建我的 custom_plan.rb 和 zeus.json 好吧

但是当我尝试创建我的并行数据库时(我有一个带有 8 个线程的 i7)我有一个奇怪的消息:

> rake parallel:create
app_development already exists
app_development already exists
app_development already exists
app_development already exists
app_development already exists
app_development already exists
app_development already exists
app_development already exists

并行尝试复制我的开发数据库?我以为他复制了我的 app_test 数据库

> rake parallel:drop
> rake parallel:create
PG::Error: ERROR:  duplicate key value violates unique constraint "pg_database_datname_index"
DETAIL:  Key (datname)=(app_development) already exists.
: CREATE DATABASE "app_development" ENCODING = 'utf8'

and

/vendor/bundle/gems/activesupport-4.1.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'PG::Error: ERROR:  duplicate key value violates unique constraint "pg_database_datname_index"

在我操作之后我只有 1 个 app_test 数据库和 1 个 app_development 数据库..

有什么想法吗? 我不碰 custom_plan.rb 和 zeus.json 宙斯还好 rspec 没问题 ruby = 2.1.3 rails = 4.1.13

最佳答案

我在使用 parallel_specs gem(不是 zeus 一个)时遇到了同样的问题 - 我相信它试图在开发环境中运行。我不确定这是我的应用程序还是 gem 中的问题,但我必须显式设置 RAILS_ENV 才能正常工作:

RAILS_ENV=test bundle exec rake parallel:setup
RAILS_ENV=test bundle exec rake parallel:spec

关于ruby-on-rails - 无法使用 zeus 的 parallel_tests 创建并行数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34635915/

相关文章:

安卓旋转处理

ruby-on-rails - 如果关系记录不存在,为什么我的 activerecord 查询不返回任何内容?

css - 歧义匹配,找到 2 个匹配 css 的元素 - Capybara

ruby-on-rails - 如何将图像存储在我的 heroku postgres 数据库中

ruby-on-rails - 如何在 Controller 和模型之间共享常量 Ruby on Rails

ruby-on-rails - 使用 after_update 方法的 Rails 堆栈级别太深

ruby-on-rails - rspec Controller 测试中的自定义请求 header 作为 rack.session 传递

ruby-on-rails - Stripe token 未附加到 Rails 应用程序的请求正文

javascript - 如何指定 Cypress 组件测试中使用哪个 .env 文件

apache-flex - QTP无法识别flex对象?