Last active
April 1, 2016 11:41
-
-
Save jwo/2054422371d2d0d1f908 to your computer and use it in GitHub Desktop.
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 'minitest/autorun' | |
class AwesomeTest < Minitest::Test | |
def test_attitude_rules | |
assert value_for('attitude') > value_for('hardwork') and value_for('attitude') > value_for('knowledge') | |
end | |
def test_knowledge_96 | |
assert_equal 96, value_for('knowledge') | |
end | |
def test_hardwork_98 | |
assert_equal 98, value_for('hardwork') | |
end | |
def test_attitude_100 | |
assert_equal 100, value_for('attitude') | |
end | |
def test_a_value_is_1 | |
assert_equal 1, value_for('a') | |
end | |
def test_z_value | |
assert_equal 26, value_for('z') | |
end | |
def test_simple_word | |
assert_equal 3, value_for('aaa') | |
end | |
def test_capital_simple_word | |
assert_equal 3, value_for('AAA') | |
end | |
private | |
def value_for word | |
word.downcase.chars.map do |char| | |
index = letters.index(char) | |
numbers[index] | |
end.reduce(:+) | |
end | |
def letters | |
('a'..'z').to_a | |
end | |
def numbers | |
(1..26).to_a | |
end | |
end |
🌹
One can simply learn minitest from this. Awesome.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rad to the bone