Makers Academy - Week 1 Pair Programming Project

Boris-bikes 🚲

Outline | Task | Installation Instructions | Functional Description | Feature Tests | User Stories | Objects & Methods | Testing | Further improvements

boris_bikes

Let's go back several years, to the days when there were no Boris Bikes. Transport for London, the body responsible for delivery of a new bike system, come to you with a plan: a network of docking stations and bikes that anyone can use. They want you to build a program that will emulate all the docking stations, bikes, and infrastructure (repair staff, and so on) required to make their dream a reality.

This challenge is the first afternoon challenge at Makers Academy.

This project is based on the User Stories listed below. Each User Story has been further broken down into Objects and Methods. Tests have been designed for all features in line with TDD best-practice.

  1. Fork this repository, clone to your local machine then change into the directory:
$ git clone https://github.com/davmcgregor/boris-bikes.git 
$ cd boris-bikes
  1. Load dependencies with bundle:
$ gem install bundle
$ bundle
  1. Run the app in the terminal:
$ irb
> require './lib/boris_bikes.rb'

The system's functionality includes:

  • A bike can be docked or relased from a docking station.
  • If a bike is reported broken then that bike cannot be relased from a docking station (it can still be returned to a).
  • Garages fix broken bikes.
  • Vans move bikes between docking stations and garages.
 > station = DockingStation.new
 > bike = Bike.new

To report a bike as broken, use .report_broken

> bike.report_broken
> bike.broken?
 => true

To dock a bike at a docking station, use .dock on the station and pass bike as an argument. An array of bikes inside the docking station can be access with .bikes. Docking will fail is the station is at capacity.,

> station.dock(bike)
> station.bikes
=> [#<Bike:0x007fea65216040 @broken=false>] 
As a person,
So that I can use a bike,
I'd like a docking station to release a bike.
As a person,
So that I can use a good bike,
I'd like to see if a bike is working
As a member of the public
So I can return bikes I've hired
I want to dock my bike at the docking station
As a member of the public
So I can decide whether to use the docking station
I want to see a bike that has been docked
As a maintainer of the system,
So that I can control the distribution of bikes,
I'd like docking stations not to accept more bikes than their capacity.
As a system maintainer,
So that I can plan the distribution of bikes,
I want a docking station to have a default capacity of 20 bikes.
As a system maintainer,
So that busy areas can be served more effectively,
I want to be able to specify a larger capacity when necessary.
As a member of the public,
So that I reduce the chance of getting a broken bike in future,
I'd like to report a bike as broken when I return it.
As a maintainer of the system,
So that I can manage broken bikes and not disappoint users,
I'd like docking stations not to release broken bikes.
As a maintainer of the system,
So that I can manage broken bikes and not disappoint users,
I'd like docking stations to accept returning bikes (broken or not).
As a maintainer of the system,
So that I can manage broken bikes and not disappoint users,
I'd like vans to take broken bikes from docking stations and deliver them to garages to be fixed.
As a maintainer of the system,
So that I can manage broken bikes and not disappoint users,
I'd like vans to collect working bikes from garages and distribute them to docking stations.

For the user stories I created a domain model for each object, including attributes and behaviour:

Object: DockingStation
Attributes: bikes capacity
Methods: release_bike dock(bike) full? empty?

Object: Bike
Attributes: broken
Methods: broken? report_broken fix

Object: Van
Attributes: van_bikes
Methods: get_bikes(station empty_van

Object: Garage
Attributes: garage_bikes
Methods: deliver_bikes(van) empty_garage

Tests were written with RSpec. To run the tests in terminal:

$> cd boris-bikes
$> rspec