Предупреждение при тестировании спецификаций в postgres: транзакции не выполняются
Для каждого шага теста происходит 2 строки:
WARNING: there is already a transaction in progress
NOTICE: there is no transaction in progress
С линиями Spork после троек:
NOTICE: there is no transaction in progress
NOTICE: there is no transaction in progress
NOTICE: there is no transaction in progress
WARNING: there is already a transaction in progress
WARNING: there is already a transaction in progress
WARNING: there is already a transaction in progress
Я не знаю, может быть, это важно, просто предупредил. Gemfile:
group :test do
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'spork-rails'
gem 'capybara'
gem 'database_cleaner'
end
все настроено, поэтому нет необходимости в разработке группы, и это все равно не помогает. это spec_helper. Я обнаружил, что это функция PostgreSQL, но я не мог найти, как ее исправить.
Буду признателен за помощь
Ответы
Ответ 1
В spec_helper.rb
я бы попытался изменить этот
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
к этому
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean_with(:truncation)
end
Ответ 2
В spec_helper.rb
config.use_transactional_examples = false #factoryGirl
config.use_transactional_fixtures = false #fixtures
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
В database.yml
test:
adapter: postgresql
encoding: unicode
host: localhost
database: myapp_test
username: my_username
password:
allow_concurrency: true
pool: 5
min_messages: error
Даже если вы установили параметр min_messages, вы все равно можете видеть вывод консоли следующим образом:
WARNING: there is already a transaction in progress
Отредактируйте файл
/opt/local/var/db/postgresql92/defaultdb/postgresql.conf
и установите следующее:
client_min_messages = error
Теперь все должно работать плавно.