- Fork this repo
- Clone your fork to your local machine
- cd calculator
- Add my repo as an upstream (
git remote add upstream [email protected]:jasonnoble/calculator.git
) git fetch upstream
bundle
Open the editor of your choice.
You should work on a topic branch. Make sure you are on the main branch:
$ git branch
* main
$
Make sure you have the latest changes:
$ git fetch upstream
$ git reset --hard upstream/main
Create a topic branch:
$ git checkout -b attempt_1
Switched to a new branch 'attempt_1'
$ git branch
* attempt_1
main
$
- Get comfortable with RSpec TDD process
- Continue practicing Ruby
- Get comfortable with staging and committing changes via
git
- You should commit at least at the end of each iteration. The more you commit, the better.
This repo has a number of automated tasks handled by the Guard gem. After creating your topic branch, run the following:
$ bundle exec guard --clear
This does a number of things:
- Runs
bundle
if you've changed your Gemfile - Runs Rubocop to analyze your Ruby code for linting issues
- Runs RSpec
Leave this command running in your terminal. Whenever you change any code, guard will notice you saved changes and re-run the steps above.
A Calculator
represents a simple calculator
Attributes:
- None
Methods:
- total (returns the current total, 0.00 by default)
Steps:
- Create a spec/calculator_spec.rb file
- Require the spec_helper
- Require './lib/calculator'
- RSpec.describe Calculator
Verify the following via your spec file:
- Creating a calculator requires no arguments
- You can ask a calculator for its total
Iteration Rubric:
- Rubocop returns no errors
- All tests are green
- Code coverage shows 100% test coverage
A Calculator
can add numbers
Methods:
- add(number)
- Adds the number to the calculator's total
Special test cases (HINT: You should have an it
block for each of these):
- Positive Numbers
- Negative Numbers
- Zero
- Decimal values (3.1415)
Iteration Rubric:
- Rubocop returns no errors
- All tests are green
- Code coverage shows 100% test coverage
A Calculator
can subtract numbers
Methods:
- subtract(number)
- Subtracts the number from the calculator's total
Special test cases:
- Positive Numbers
- Negative Numbers
- Zero
- Decimal values (3.1415)
Iteration Rubric:
- Rubocop returns no errors
- All tests are green
- Code coverage shows 100% test coverage
A Calculator
can multiply numbers
Methods:
- multiply(number)
- Multiply the calculator's total by the number
Special test cases (HINT: For all these, but the last one, you probably want to call calculator.add(2)
before calling calculator.multiply(number)
:
- Positive Numbers
- Negative Numbers
- Zero
- Decimal values (3.1415)
- Calculators total is zero
Iteration Rubric:
- Rubocop returns no errors
- All tests are green
- Code coverage shows 100% test coverage
A Calculator
can divide numbers
Methods:
- divide(number)
- Divides the calculator's total by the number
Special test cases:
- Positive Numbers
- Negative Numbers
- Zero (HINT:
...).to be_infinite)
- Decimal values (3.1415)
- Calculators total is zero
Iteration Rubric:
- Rubocop returns no errors
- All tests are green
- Code coverage shows 100% test coverage
A Calculator
can clear its total
Methods:
- clear
- resets the total to 0.00
Iteration Rubric:
- Rubocop returns no errors
- All tests are green
- Code coverage shows 100% test coverage
After you've committed all your results via Git, you can check your work by running the following:
$ git diff upstream/complete
$ git checkout main
$ git fetch upstream
$ git reset --hard upstream/main
$ git checkout -b attempt_2
Repeat this process until you can do it quickly, without struggling.