This is a learning situation, to demonstrate your capabilities regarding testing.
-
Fork this repo.
-
Outside your Docker container, in the same directory as your
compose.ymlfile that you've been using for the quarter project, clone the repository specifically like this:git clone [your fork clone URL] cs362-cold-beveragesIf you forget that last argument, rename your cloned directory to
cs362-cold-beveragesbefore proceeding. -
Edit
compose.yml. You need to add the following line to thevolumessection if it's not there already:- ./cs362-cold-beverages:/home/user/cs362-cold-beverages -
Run the container. You should be able to see your
cs362-cold-beveragesdirectory in there
There is a Gemfile, so install the dependencies with bundle install.
The only dependency is rspec.
You have just taken over a legacy implementation of a refrigerator simulator. There is an example program that "drives" the simulation. Run it:
ruby lib/driver.rb
You should see the output of the status of a single refrigerator: once while it is empty and hasn't been plugged in, and then its status after being plugged in and used.
Look at lib/driver.rb to get a feel for how one can create
refrigerator components, assemble them to create a refrigerator, and use
the refrigerator.
Run the test suite.
rspec
You should see a handful of skipped tests and one failing test.
Read the tests in spec/vessel_spec.rb.
Take a look at which test is failing, and fix the implementation in
lib/vessel.rb to get the test to pass.
Focus on the remaining tests in spec/vessel_spec.rb. Perform a TDD
workflow by removing each skip and getting each test to pass by
implementing new code in lib/vessel.rb.
Ideally, be sure that all of your Vessel tests are passing before you continue to Step 3.
Now, your goal is to examine this legacy codebase and get as much of it under test as possible. There are many paths you may take, techniques you may use, and there is probably more code to test than what you have time for. Make your decisions and be methodical. One suggested order to pursue is:
- Item
- WaterDispenser
- WaterReservoir
- Freezer
- Chiller
- Refrigerator
Do not try to be too clever with your tests. Be methodical, straightforward, and explicit.
Run the driver again. Notice how the water reservoir starts with "0
remaining" and then after some simulated use reports that there is "-2
remaining". Look at the code in lib/driver.rb, and look at the
WaterReservoir class.
See if you can keep your test suite green while you:
-
Modify the behavior in either
WaterDispenserorWaterReservoir, to prevent the remaining volume of water from ever becoming negative. ("Where?" is a design decision you have to make, and "How?" is your creative output.) -
Test this new behavior you have introduced.
-
Modify the behavior in the
WaterDispenserclass to not only drain the reservoir according to the volume of the vessel, but to also "fill" the vessel. -
Test this new behavior you have introduced.
Create a pull request.