benfurber / bank_ruby

A dummy tech test built in Ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bank

A dummy tech test built in Ruby.

Task

Screenshot of bank in action

The task was to build a simple bank that users would access via a REPL. Users must be able to make deposits and withdrawals as well as print account statements that show each transaction with the date, amount and balance.

I started by drafting the requirements into user stories with individual acceptance criteria and used those stories to draft a basic representation of how I saw those stories working as a set of classes, methods and states.

I followed standard TDD principles for this project by drafting tests in RSpec before coding my model, keeping an eye on my test coverage by using SimpleCov and regularly running Rubocop to check my grammar.

I considered how much delegation (and thus objects) was reasonable for this project considering the scope. My first draft had two objects, one for the account and a another for transactions. After completing those two, I decided a third sense for printing the statement. This was because more complexity was needed for it than I initially thought and so it made sense to delegate that code away from Account. I did consider doing separate objects for deposits and withdrawals (sharing attributes through a module), but as only a string separates their functional difference it seemed like too much.

One small bonus functionality is about the date. By default the day's date is added by a transaction, but the user can choose to provide a custom date of their own in a strict dd/mm/yyyy format.

Prerequisites

  1. Ruby is installed
  2. RubyGems is installed
  3. Bundler is installed:
gem install bundler

Installing

git clone https://github.com/benfurber/bank_ruby
cd bank_ruby
bundle install

Run the tests

rspec

To run

Once cloned and in the root directory run:

irb -r ./lib/account.rb

In IRB, set-up a bank account:

> account = Account.new

In IRB, make a deposit:

> account.deposit(amount, optional_date)

In IRB, make a withdraw:

> account.deposit(amount, optional_date)

In IRB, print a statement:

> account.statement

Full example:

> account = Account.new
> account.deposit(1000, '10/01/2012')
> account.deposit(2000, '13/01/2012')
> account.withdraw(500, '14/01/2012')
> puts account.statement

Built With

Contributing

This is just a dummy tech test I was doing so I really shouldn't accept any contributes, sorry.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

About

A dummy tech test built in Ruby

License:MIT License


Languages

Language:Ruby 100.0%