Instructions
Create a function add that takes two numbers and returns their sum.
Hints:
- Use the + operator
Your Code
def add(a, b) a + b end
RSpec.describe "add" do
it "adds positive numbers" do
expect(add(2, 3)).to eq(5)
end
it "adds negative numbers" do
expect(add(-1, -2)).to eq(-3)
end
it "adds zero" do
expect(add(5, 0)).to eq(5)
end
end
Results
Click "Run Tests" to see results
1 / 4
Next: Sum an Array