10

Per ogni fase del test di verifica 2 linee:Attenzione durante il test specifiche sul Postgres: non v'è alcuna transazione in corso

WARNING: there is already a transaction in progress 
NOTICE: there is no transaction in progress 

con linee Spork seguenti triple:

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 

non so forse è importante, solo avvertito. GemFile:

group :test do 
    gem 'rspec-rails' 
    gem 'factory_girl_rails' 
    gem 'spork-rails' 
    gem 'capybara' 
    gem 'database_cleaner' 
end 

tutto personalizzato, quindi non è necessario per sviluppare gruppo, e non aiuta comunque. this is spec_helper. Ho scoperto che si tratta di funzionalità PostgreSQL, ma non sono riuscito a trovare il modo di risolverlo. Sarò grato per l'assistenza

+1

Il tuo link al tuo 'spec_helper.rb' sembra essere rotto. Quale strategia di pulizia del database stai usando? Transazione o troncamento? Se stai usando il primo, potrei provare quest'ultimo. –

+0

Grazie, l'ho spostato su github gist. – zishe

risposta

9

In spec_helper.rb, vorrei provare a cambiare questa

config.before(:suite) do 
    DatabaseCleaner.strategy = :transaction 
    DatabaseCleaner.clean_with(:truncation) 
    end 

a questo

config.before(:suite) do 
    DatabaseCleaner.strategy = :truncation 
    DatabaseCleaner.clean_with(:truncation) 
    end 
+0

Ho provato, ma funziona estremamente lento anche con spork. – zishe

+0

Potrebbe essere normale, a seconda di quanti test hai e quanti oggetti stai creando e cosa consideri estremamente lento. –

+0

Ma con questo avviso funziona correttamente, solo al mio capo non piace, credo. – zishe

11

In 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 

Nel database. yml

test: 
    adapter: postgresql 
    encoding: unicode 
    host: localhost 
    database: myapp_test 
    username: my_username 
    password: 
    allow_concurrency: true 
    pool: 5 
    min_messages: error 

Anche se è stata impostata l'opzione min_messages, si può ancora vedere l'output su console come la seguente:

WARNING: there is already a transaction in progress 

Modificare il file

/opt/local/var/db/postgresql92/defaultdb/postgresql.conf 

e impostare la seguente:

client_min_messages = error 

Ora tutto dovrebbe funzionare senza intoppi.

+2

config.use_transactional_examples = false Ha funzionato per me. –

+0

config.use_transactional_fixtures = false #fixtures ha funzionato per me! :) – squiter

Problemi correlati