Sha256: 34f849e558b94795a2f2afbdcf2b8d3e1be8f84252214a66d33f92feab327957
Contents?: true
Size: 799 Bytes
Versions: 10
Compression:
Stored size: 799 Bytes
Contents
require 'spec_helper' unless ActiveRecord::Migration.table_exists?(:models) ActiveRecord::Migration.create_table(:models) end class Model < ActiveRecord::Base; end RSpec.describe 'Transactions' do before do stub_const 'RollBackTransactions', Class.new stub_const 'NestedRoutine', Class.new NestedRoutine.class_eval do lev_routine def exec raise 'Rolled back' end end RollBackTransactions.class_eval do lev_routine uses_routine NestedRoutine def exec Model.create! run(:nested_routine) end end end context 'in nested routines' do it 'rolls back on exceptions' do expect { RollBackTransactions.call }.to raise_error expect(Model.count).to eq(0) end end end
Version data entries
10 entries across 10 versions & 1 rubygems