January 2020
Intermediate to advanced
532 pages
13h 31m
English
In our example, the open_account function calls several dependent functions. It performs background checks for a customer, creates the account, and notifies downstream systems. Practically speaking, we may want to create stubs for all of them. How do we apply multiple stubs? The Mocking package supports this feature.
As usual, we would need to decorate the open_account function with a @mock macro for every function that we want to apply to our stubs. The following code shows this:
function open_account(first_name, last_name, email) @mock(check_background(first_name, last_name)) || return :failure account_number = @mock(create_account(first_name, last_name, email)) @mock(notify_downstream(account_number)) ...
Read now
Unlock full access