The first pairing project in the Makers Web Development Bootcamp, Week 1
The idea behind this 22 step challenge is to familiarize ourselves with practical Test Driven Development using RSpec, Ruby, the command line (pry or irb), git, and GitHub. We also track our progress, learning experiences and goals on Diode.
I wrote out my process in this README file, as a reminder for when I attempt the air traffic controller challenge.
Translate two user stories -
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
into a functional representation inside a table, sorted by nouns and verbs
NOUNS person, docking station, bike
VERBS use, release, see (if working)
TABLE
Objects | Messages |
---|---|
docking_station | release |
bike | bike_works? |
docking_station --> release_bike --> bike --> person
person --> bike_works? --> use_bike
In 3. we created this error:
2.4.1 :001 > docking_station = DockingStation NameError: uninitialized constant DockingStation from (irb):1 from /Users/username/.rvm/rubies/ruby-2.2.2/bin/irb:11:in '<main>'
Type of error: Name error
File path: /Users/username/.rvm/rubies/ruby-2.2.2/bin/irb:11:in '<main>'
Line number: 1
What does it mean?: the name we wrote down is undefined
How to solve error?: Define or initialize the name
Although we ran Rspec, we got a Ruby error only. This is because we have not written any Rspec rules/tests for our code yet (we think).
Created new file for DockingStation class, and defined the class. Used require to link files. Explained difference in rspec findings.
New user story:
As a member of the public,
So that I am not confused and charged unnecessarily,
I'd like docking stations not to release bikes when there are none available.
Learnt new Ruby fail
method, and RSpec {} syntax for exceptions
New user story:
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.
Added error message if docking station ran out of space (full capacity) and stops user from docking bike there.
New user story:
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.
Wrapped collections
New user story:
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.
Took way too long to fix newly introduced errors here; lots of going back to previous exercises.
Solution was in understanding the difference between constant and instance variables, and where to use them.
Onwards to the airport challenge!!!