Skip to content

Instantly share code, notes, and snippets.

@southgate
Created September 30, 2014 21:46
Show Gist options
  • Save southgate/6c2190106e356531e664 to your computer and use it in GitHub Desktop.
Save southgate/6c2190106e356531e664 to your computer and use it in GitHub Desktop.

So say you were doing this in ruby and you wanted to write a method sum that took numbers and added them together. You'd have one ruby file that contained your test, call it math_test.rb, and one ruby file that contained your method, call it math.rb. They'd look something like this:

math_test.rb:

def test_summation
  assert 4 == sum(2, 2)
  assert 0 == sum(2, -2)
end

Initially if you ran math_test.rb without math.rb it's gonna fail. Then you write math.rb:

def sum(a, b)
  a + b
end

And now if you run math_test.rb the test should pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment