-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathsplitter_spec.rb
More file actions
41 lines (35 loc) · 1.17 KB
/
splitter_spec.rb
File metadata and controls
41 lines (35 loc) · 1.17 KB
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
# frozen_string_literal: true
require 'spec_helper'
describe SplitIoClient::Splitter do
RSpec.shared_examples 'Splitter' do |file, algorithm|
it 'returns expected hash and bucket' do
File.foreach(file, encoding: 'UTF-8') do |row|
seed, key, hash, bucket = row.split(',')
expect(described_class.new.count_hash(key, seed.to_i, algorithm)).to eq(hash.to_i)
expect(described_class.new.bucket(hash.to_i)).to eq(bucket.to_i)
end
end
end
describe 'using mumur3 algorithm' do
it_behaves_like(
'Splitter',
File.expand_path(File.join(File.dirname(__FILE__), '../../test_data/hash/murmur3-sample-data-v2.csv')),
false
)
end
describe 'using mumur3 algorithm with non-alphanumeric sample data' do
it_behaves_like(
'Splitter',
File.expand_path(File.join(File.dirname(__FILE__),
'../../test_data/hash/murmur3-sample-data-non-alpha-numeric-v2.csv')),
false
)
end
describe 'using legacy algorithm' do
it_behaves_like(
'Splitter',
File.expand_path(File.join(File.dirname(__FILE__), '../../test_data/hash/sample-data.csv')),
true
)
end
end