Created
November 4, 2017 04:58
-
-
Save sergiomaia/b3b1e9e597da79d25ced18ea10113564 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
require 'rspec' | |
string_collection = [ | |
"Web IconHTML & CSS100%", | |
"Command LineLearn the Command Line100%", | |
"Ruby IconRuby50%", | |
"Rails IconLearn Ruby on Rails100%", | |
"Git IconLearn Git100%", | |
"SassLearn Sass20%", | |
"JQuery IconjQuery1%", | |
"Angular JSLearn AngularJS 1.X100%", | |
"Javascript IconLearn JavaScript55%" | |
] | |
def string_parser string_collection | |
results = [] | |
string_collection.each do |str| | |
results << str.scan(/\d+/).last.to_i | |
end | |
results | |
end | |
describe "String Parser" do | |
it 'can take a string and output the correct values' do | |
expect(string_parser(string_collection)).to eq([100, 100, 50, 100, 100, 20, 1, 100, 55]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment