无法使用带有zeus的parallel_tests创建并行数据库

时间:2016-01-06 14:46:27

标签: ruby-on-rails testing rspec zeus

我有一个带有zeus-parallel_tests的问题及其初始化:

我的gemfile:

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 好的

但是当我尝试创建我的parallels数据库(我有一个带有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

2 个答案:

答案 0 :(得分:5)

我使用parallel_specs gem(而非zeus gem)遇到了同样的问题 - 我相信它正试图在开发环境中运行。我不确定这是我的应用程序或gem中的问题,但我必须明确设置RAILS_ENV才能使用:

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

答案 1 :(得分:1)

我相信这是因为Spring,rake命令使用它。尝试禁用它或patching