Last active
October 19, 2015 00:41
-
-
Save srt32/56cd909626d9afc8713b to your computer and use it in GitHub Desktop.
Example from https://github.com/turingschool/enums-exercises/blob/master/test/solutions/reduce_test.rb
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' | |
require 'minitest/autorun' | |
class ReduceTest < Minitest::Test | |
def test_capitalize_keywords_in_phrase_one_fish_two_fish_red_fish_blue_fish | |
keywords = ["fish", "blue"] | |
phrase = 'one fish two fish red fish blue fish' | |
result = phrase.split.reduce do |updatedPhrase, word| | |
new_word = word | |
if keywords.include?(word) | |
new_word = word.upcase | |
end | |
updatedPhrase + " " + new_word # we want to keep a space between words | |
end | |
assert_equal 'one FISH two FISH red FISH BLUE FISH', result | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment