Created
August 21, 2014 04:43
-
-
Save ryanswood/c5f8e93305c4654b658b 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
| class PigLatin | |
| def initialize | |
| end | |
| def convert(original_string) | |
| word_collection = original_string.split(" ").map(&:downcase) | |
| word_collection.map! do |word| | |
| word.match(/(.)(.+)/) | |
| $2 + $1 + "ay" | |
| end | |
| word_collection.join(" ") | |
| end | |
| end |
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 './pig_latin' | |
| describe PigLatin do | |
| let(:pl) { PigLatin.new } | |
| describe "#converter" do | |
| it "accepts an argument" do | |
| expect{pl.convert("Hello, World")}.not_to raise_error | |
| end | |
| it "returns the correct output" do | |
| expect(pl.convert("Hello World")).to eq("ellohay orldway") | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Boom!