Created
September 19, 2013 22:14
-
-
Save armonge/6630595 to your computer and use it in GitHub Desktop.
Kata #1 (ruby) Webcast Agilityfeat. https://plus.google.com/114642677983172790710/posts/erAyjcXgkLp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fizzbuzz(number) | |
if number == 0 | |
return '0' | |
elsif number % 15 == 0 | |
return 'fizzbuzz' | |
elsif number % 3 == 0: | |
return 'fizz' | |
elsif number % 5 == 0: | |
return 'buzz' | |
end | |
return number.to_s | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fizzbuzz' | |
require 'test/unit' | |
class TC_FizzBuzz < Test::Unit::TestCase | |
def test_classify_as_is | |
assert_equal('0', fizzbuzz(0)) | |
assert_equal('1', fizzbuzz(1)) | |
end | |
def test_classify_as_fizz | |
assert_equal('fizz', fizzbuzz(3)) | |
assert_equal('fizz', fizzbuzz(6)) | |
end | |
def test_classify_as_buzz | |
assert_equal('buzz', fizzbuzz(10)) | |
assert_equal('buzz', fizzbuzz(5)) | |
end | |
def test_classify_as_fizzbuzz | |
assert_equal('fizzbuzz', fizzbuzz(30)) | |
assert_equal('fizzbuzz', fizzbuzz(15)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment