Red Green Repeat Adventures of a Spec Driven Junkie

TDD Practice - Divide without Divide (continued)

So, did you have a solution to implement divide without /? The following test from this post?

it 'divides by 1' do
  divide(1,1).to eq(1)
end

In a coaching session, I would evaluate what you wrote and provide feedback. In a blog post format, it’s harder and I would add a test so the test file looks like:

it 'divides by 1' do
  divide(1,1).to eq(1)
end

it 'divides by 2' do
  divide(1,2).to eq(0)
end

Run the tests, do any fail? Which ones? Do they all pass?

If there is a failure, update the function:

def divide(a,b)
   # whatever you want
end

Now, what does the divide function look like? Are there any changes for the new test? If so, why? If not, why not?

This about this before moving on to the next post?