-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathword_in_string_spec.rb
47 lines (43 loc) · 1.23 KB
/
word_in_string_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require_relative 'spec_helper'
require_relative 'parser'
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
end
it "should return :yes for word_in_string?('grow', 'miracle grow')" do
expect(word_in_string?('grow', 'miracle grow')).to eq :yes
end
end
context "should detect whole words; e.g.:" do
[
['book', 'book'],
['book', 'book_shelf'],
['book', 'note_book_shelf'],
['book', 'note_book'],
["book", "note_book-"],
["cat", "bodega-cat"],
["cat", "bodega cat"],
].each do |test|
word, string = *test
it "should detect '#{word}' in '#{string}'" do
expect(word_in_string?(word, string)).to eq :yes
end
end
end
context "should not count words within words; e.g.:" do
[
["book", "bookshelf"],
["book", "notebook"],
["lap", "lapaz"],
["apa", "lapaz"],
["cat", "c a t"],
].each do |test|
word, string = *test
it "should not detect '#{word}' in '#{string}'" do
expect(word_in_string?(word, string)).to eq :no
end
end
end
end