GithubHelp home page GithubHelp logo

jcanepa / cs362-cold-beverages Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ybakos/cs362-cold-beverages

0.0 0.0 0.0 141 KB

Stick it in da fridge stick it in da fridge stick it in da fridge, in da fridge.

Home Page: https://www.youtube.com/watch?v=pk9-28HgxfE

Ruby 100.00%

cs362-cold-beverages's Introduction

Exam: A Refrigerator Simulator

This is a learning situation, to demonstrate your capabilities regarding testing.

Setup

Fork and clone the repository. There is a Gemfile, so install the dependencies with bundle install. The only dependency is rspec.

Scenario

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.

What to do

Run the test suite.

rspec

You should see a handful of skipped tests and one failing test.

Step 1

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.

Step 2

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.

Step 3

Note: Be sure to leave yourself at least 20 minutes for Step 4.

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.

Step 4

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:

  1. Modify the behavior in either WaterDispenser or WaterReservoir, 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.)
  2. Test this new behavior you have introduced.
  3. Modify the behavior in the WaterDispenser class to not only drain the reservoir according to the volume of the vessel, but to also "fill" the vessel.
  4. Test this new behavior you have introduced.

Step 5

Create a pull request.

© 2021 Yong Bakos. All rights reserved.

cs362-cold-beverages's People

Contributors

jcanepa avatar ybakos 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.