Skip to content

Instantly share code, notes, and snippets.

@ryo-utsunomiya
Created February 3, 2016 18:23
Show Gist options
  • Save ryo-utsunomiya/7dbfe1e39fb126af2252 to your computer and use it in GitHub Desktop.
Save ryo-utsunomiya/7dbfe1e39fb126af2252 to your computer and use it in GitHub Desktop.
require 'minitest/autorun'
def fizzbuzz(n)
return 'FizzBuzz' if n % 15 == 0
return 'Buzz' if n % 5 == 0
return 'Fizz' if n % 3 == 0
n
end
class TestFizzBuzz < Minitest::Test
def test_fizz
assert_equal 'Fizz', fizzbuzz(3)
end
def test_buzz
assert_equal 'Buzz', fizzbuzz(5)
end
def test_fizzbuzz
assert_equal 'FizzBuzz', fizzbuzz(15)
end
def test_others
assert_equal 1, fizzbuzz(1)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment