-
-
Save klmlfl/e4a3094857e032683426 to your computer and use it in GitHub Desktop.
This file contains 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
class Fixnum | |
def to_roman | |
roman_numerals_values = {1000 => 'M',500 => 'D', 100 => 'C', 50 => 'L', 10 => 'X', 5 => 'V', 1 => 'I'} | |
string = String.new | |
roman_numerals_values.each do |k,v| | |
if self - k >= 0 | |
string << v | |
end | |
string | |
end | |
end | |
end |
This file contains 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 'minitest/autorun' | |
require_relative 'roman' | |
class RomanTest < MiniTest::Unit::TestCase | |
def test_1 | |
assert_equal 'I', 1.to_roman | |
end | |
def test_2 | |
skip | |
assert_equal 'II', 2.to_roman | |
end | |
end |
This file contains 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
Shabans-MacBook-Air-3:~/exercism/ruby/roman-numerals$ ruby roman_numerals_test.rb | |
MiniTest::Unit::TestCase is now Minitest::Test. From roman_numerals_test.rb:4:in `<main>' | |
Run options: --seed 28854 | |
# Running: | |
SSSSSSSSSSSSSSSFSS | |
Finished in 0.058014s, 310.2699 runs/s, 17.2372 assertions/s. | |
1) Failure: | |
RomanTest#test_1 [roman_numerals_test.rb:7]: | |
--- expected | |
+++ actual | |
@@ -1 +1 @@ | |
-"I" | |
+{1000=>"M", 500=>"D", 100=>"C", 50=>"L", 10=>"X", 5=>"V", 1=>"I"} | |
18 runs, 1 assertions, 1 failures, 0 errors, 17 skips | |
You have skipped tests. Run with --verbose for details. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment