-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Namae | ||
describe 'Parser using threads' do | ||
let(:name_1_str) { "Foo Bar" } | ||
let(:name_2_str) { "Baz" } | ||
let(:name_1) { Namae.parse(name_1_str).first } | ||
let(:name_2) { Namae.parse(name_2_str).first } | ||
|
||
def compare(string, expectation) | ||
name = Namae.parse(string).first | ||
given_name_match = expectation.given == name.given | ||
family_name_match = expectation.family == name.family | ||
raise unless given_name_match && family_name_match | ||
end | ||
|
||
it 'has no conflicts' do | ||
[[name_1_str, name_1], [name_2_str, name_2]].map do |string, expectation| | ||
Thread.new do | ||
1000.times do | ||
compare(string, expectation) | ||
end | ||
end | ||
end.each(&:join) | ||
end | ||
end | ||
end |