Skip to content

Instantly share code, notes, and snippets.

@myronmarston
Created March 6, 2015 04:09
Show Gist options
  • Save myronmarston/e79cbff12ce51b54814b to your computer and use it in GitHub Desktop.
Save myronmarston/e79cbff12ce51b54814b to your computer and use it in GitHub Desktop.
class SomeEntity
def run
transaction do
mark_non_eligible
make_invoice_batch
send_batch_email
end
end
def transaction
yield
end
def mark_non_eligible
end
def make_invoice_batch
end
def send_batch_email
end
end
RSpec.describe SomeEntity do
it 'wraps the processing in a transaction' do
entity = SomeEntity.new
expect(entity).to receive(:transaction).and_yield do |transaction_scope|
expect(transaction_scope).to receive(:mark_non_eligible)
expect(transaction_scope).to receive(:make_invoice_batch)
expect(transaction_scope).to receive(:send_batch_email)
end
entity.run
end
end
@novikserg
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment