Skip to content

Commit

Permalink
Add test to prove threading works
Browse files Browse the repository at this point in the history
  • Loading branch information
hackling authored and inukshuk committed Nov 30, 2017
1 parent 5fad0bf commit 3cf8d6c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spec/namae/threading_spec.rb
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

0 comments on commit 3cf8d6c

Please sign in to comment.