Created
March 6, 2015 04:09
-
-
Save myronmarston/e79cbff12ce51b54814b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍