zis*_*she 10 postgresql unit-testing transactions ruby-on-rails ruby-on-rails-3
每个测试步骤发生2行:
WARNING: there is already a transaction in progress
NOTICE: there is no transaction in progress
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
我不知道也许这很重要,只是警告.的Gemfile:
group :test do
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'spork-rails'
gem 'capybara'
gem 'database_cleaner'
end
Run Code Online (Sandbox Code Playgroud)
所有定制,所以没有必要开发组,无论如何它都没有帮助.这是spec_helper.我发现,它是PostgreSQL功能,但我找不到如何修复它.我将不胜感激
And*_*tad 11
在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
Run Code Online (Sandbox Code Playgroud)
在database.yml中
test:
adapter: postgresql
encoding: unicode
host: localhost
database: myapp_test
username: my_username
password:
allow_concurrency: true
pool: 5
min_messages: error
Run Code Online (Sandbox Code Playgroud)
即使您已设置min_messages选项,您仍可能会看到如下控制台输出:
WARNING: there is already a transaction in progress
Run Code Online (Sandbox Code Playgroud)
编辑文件
/opt/local/var/db/postgresql92/defaultdb/postgresql.conf
Run Code Online (Sandbox Code Playgroud)
并设置以下内容:
client_min_messages = error
Run Code Online (Sandbox Code Playgroud)
现在一切都应该顺利进行.
在spec_helper.rb,我会尝试改变这一点
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
Run Code Online (Sandbox Code Playgroud)
对此
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean_with(:truncation)
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5950 次 |
| 最近记录: |