Giter VIP home page Giter VIP logo

bank_tech_test_ruby's Introduction

Bank Tech Test in Ruby

Description:

The program acts as a simple account keeping solution. It lets user to create an account, make debit and credit transactions, and print a statement. The program manages the current balance as well.

Instructions for how to run the program

$ git clone https://github.com/peter-miklos/bank_tech_test_ruby.git
$ bundle
$ rspec

Use IRB to interact with the code. User stories

As a User
So that I can manage my financials
I want to open an account

As a User
So that I can use the money on my account
I want to make credit and debit transactions

As a User
So that I can plan my future spending and check transaction history
I want to see an account statement

Tests

Feature tests

The program's main features are tested in IRB:

2.3.1 :001 > require './lib/account.rb'
 => true
2.3.1 :002 > account = Account.new
 => #<Account:0x007fd8e2a05f38 @transaction_log=#<TransactionLog:0x007fd8e2a05f10 @transactions=[], @transaction_class=Transaction>, @statement_engine=#<StatementEngine:0x007fd8e2a05e48>, @balance=0>
2.3.1 :003 > account.deposit(1000)
 => 1000
2.3.1 :004 > account.deposit(200)
 => 1200
2.3.1 :005 > account.print_statement
date || credit || debit || balance
18/10/2016 || 200.00 || || 1200.00
18/10/2016 || 1000.00 || || 1000.00
 => nil
2.3.1 :006 > account.withdraw(333)
 => 867
2.3.1 :007 > account.print_statement
date || credit || debit || balance
18/10/2016 || || 333.00 || 867.00
18/10/2016 || 200.00 || || 1200.00
18/10/2016 || 1000.00 || || 1000.00

Unit tests

The following unit tests are used:

Account
  balance
    starts with 0 as opening balance if account instantiated w/o opening balance
    starts with 10 as opening balance if account instantiated with 10 units
  #deposit
    calls the deposit method on transaction_log
    adds the amount to the current balance
  #withdrawn
    calls the withdraw method on transaction_log
    deducts the amount from the current balance
  #print_statement
    calls the print_statement method on the statement engine

StatementEngine
  #print_statement
    prints out the statement with header

TransactionLog
  #deposit
    create credit transaction and add it to transactions array
    raises error if amount is not a Fixnum
    raises error if amount < 1
  #withdraw
    creates debit transaction and add it to transactions array
    raises error if amount is not a Fixnum
    raises error if amount < 1
    raises error if the new_balance < 0
  #transactions
    returns the array of transactions

Transaction
  #amount
    returns the credit amount
    returns the debit amount
  #type
    returns the type of a credit transaction
    returns the type of a debit transaction
  #date
    returns the date of credit transaction
    returns the date of the debit transaction
  #balance
    returns the balance after the credit transaction is created
    returns the balance after the debit transaction is created

bank_tech_test_ruby's People

Contributors

peter-miklos avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.