Skip to content

Commit acdfa52

Browse files
committed
minor test improvements
1 parent 231c8cc commit acdfa52

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

spec/evaluation_spec.rb

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,20 @@
129129
end
130130

131131
describe "bucket_user" do
132+
it "gets expected bucket values for specific keys" do
133+
user = { key: "userKeyA" }
134+
bucket = bucket_user(user, "hashKey", "key", "saltyA")
135+
expect(bucket).to be_within(0.0000001).of(0.42157587);
136+
137+
user = { key: "userKeyB" }
138+
bucket = bucket_user(user, "hashKey", "key", "saltyA")
139+
expect(bucket).to be_within(0.0000001).of(0.6708485);
140+
141+
user = { key: "userKeyC" }
142+
bucket = bucket_user(user, "hashKey", "key", "saltyA")
143+
expect(bucket).to be_within(0.0000001).of(0.10343106);
144+
end
145+
132146
it "can bucket by int value (equivalent to string)" do
133147
user = {
134148
key: "userkey",
@@ -137,8 +151,10 @@
137151
intAttr: 33333
138152
}
139153
}
140-
stringResult = bucket_user(user, "key", "stringAttr", "salt")
141-
intResult = bucket_user(user, "key", "intAttr", "salt")
154+
stringResult = bucket_user(user, "hashKey", "stringAttr", "saltyA")
155+
intResult = bucket_user(user, "hashKey", "intAttr", "saltyA")
156+
157+
expect(intResult).to be_within(0.0000001).of(0.54771423)
142158
expect(intResult).to eq(stringResult)
143159
end
144160

@@ -149,7 +165,7 @@
149165
floatAttr: 33.5
150166
}
151167
}
152-
result = bucket_user(user, "key", "floatAttr", "salt")
168+
result = bucket_user(user, "hashKey", "floatAttr", "saltyA")
153169
expect(result).to eq(0.0)
154170
end
155171

@@ -161,7 +177,7 @@
161177
boolAttr: true
162178
}
163179
}
164-
result = bucket_user(user, "key", "boolAttr", "salt")
180+
result = bucket_user(user, "hashKey", "boolAttr", "saltyA")
165181
expect(result).to eq(0.0)
166182
end
167183
end

0 commit comments

Comments
 (0)