Skip to content
Open

Pr-9 #10

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions acronym.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Acronym
def self.abbreviate(value)
value.scan(/\b\w/).map(&:upcase).join
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a descriptive variable and an explicit return here?

end
end
40 changes: 40 additions & 0 deletions acronym_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require 'minitest/autorun'
require_relative 'acronym'

# Common test data version: 1.7.0 cacf1f1
class AcronymTest < Minitest::Test
def test_basic
# skip
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this commented out code.

assert_equal "PNG", Acronym.abbreviate('Portable Network Graphics')
end

def test_lowercase_words
skip
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to remove skip to make sure the tests are passing.

assert_equal "ROR", Acronym.abbreviate('Ruby on Rails')
end

def test_punctuation
skip
assert_equal "FIFO", Acronym.abbreviate('First In, First Out')
end

def test_all_caps_word
skip
assert_equal "GIMP", Acronym.abbreviate('GNU Image Manipulation Program')
end

def test_punctuation_without_whitespace
skip
assert_equal "CMOS", Acronym.abbreviate('Complementary metal-oxide semiconductor')
end

def test_very_long_abbreviation
skip
assert_equal "ROTFLSHTMDCOALM", Acronym.abbreviate('Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me')
end

def test_consecutive_delimiters
skip
assert_equal "SIMUFTA", Acronym.abbreviate('Something - I made up from thin air')
end
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we want to happen if the value is nil?

end