You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the hanami framework and the rspec lib to test my code and PG database. When I trying to test one action I get following error:
PG::InFailedSqlTransaction: ERROR: current transaction is aborted, commands ignored until end of transaction block
My action has been wrapped in repository transaction:
def call(params, dependencies)
begin
dependencies.repository.transaction do
create_user(params, dependencies)
assign_tags(params, dependencies)
assign_notes(params, dependencies)
end
rescue Hanami::Model::Error, Domain::Errors::Exception => error
raise Domain::Errors::CreateUserFailed, error.message
end
end
Here you can see part of my test which are failing:
it 'should raise exception if params contains duplicated email' do
expect{service.call(duplicated_email)}
.to raise_exception(Domain::Errors::CreateUserFailed)
.with_message('Duplicated values found (id or
email)')
end
it 'should raise exception if params contains duplicated note id' do
expect{service.call(duplicated_note_id)}
.to raise_exception(Domain::Errors::CreateUserFailed)
end
First test pass but the second one raises exception I mentioned earlier. I know this is caused that previous test raised exception in transaction block. I tried to configure DB cleaner to fix this but without success.
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with :deletion
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end
The text was updated successfully, but these errors were encountered:
Hi,
I am using the hanami framework and the rspec lib to test my code and PG database. When I trying to test one action I get following error:
PG::InFailedSqlTransaction: ERROR: current transaction is aborted, commands ignored until end of transaction block
My action has been wrapped in repository transaction:
Here you can see part of my test which are failing:
First test pass but the second one raises exception I mentioned earlier. I know this is caused that previous test raised exception in transaction block. I tried to configure DB cleaner to fix this but without success.
The text was updated successfully, but these errors were encountered: