diff --git a/parser.rb b/parser.rb index adaad3e..2093d59 100644 --- a/parser.rb +++ b/parser.rb @@ -1,3 +1,9 @@ def word_in_string?(word, string) - # implement with your code here + regex = /(\A|\W|[_])#{word}(\W|\z|[_])/ + + if(regex =~ string) + :yes + else + :no + end end diff --git a/word_in_string_spec.rb b/word_in_string_spec.rb index 43c801f..2920d81 100644 --- a/word_in_string_spec.rb +++ b/word_in_string_spec.rb @@ -3,6 +3,7 @@ require 'pry' describe "word_in_string?" do + context "returns symbols :yes and :no" do it "should return :no for word_in_string?('grow', 'growler')" do expect(word_in_string?('grow', 'growler')).to eq :no