|
129 | 129 | end |
130 | 130 |
|
131 | 131 | 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 | + |
132 | 146 | it "can bucket by int value (equivalent to string)" do |
133 | 147 | user = { |
134 | 148 | key: "userkey", |
|
137 | 151 | intAttr: 33333 |
138 | 152 | } |
139 | 153 | } |
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) |
142 | 158 | expect(intResult).to eq(stringResult) |
143 | 159 | end |
144 | 160 |
|
|
149 | 165 | floatAttr: 33.5 |
150 | 166 | } |
151 | 167 | } |
152 | | - result = bucket_user(user, "key", "floatAttr", "salt") |
| 168 | + result = bucket_user(user, "hashKey", "floatAttr", "saltyA") |
153 | 169 | expect(result).to eq(0.0) |
154 | 170 | end |
155 | 171 |
|
|
161 | 177 | boolAttr: true |
162 | 178 | } |
163 | 179 | } |
164 | | - result = bucket_user(user, "key", "boolAttr", "salt") |
| 180 | + result = bucket_user(user, "hashKey", "boolAttr", "saltyA") |
165 | 181 | expect(result).to eq(0.0) |
166 | 182 | end |
167 | 183 | end |
|
0 commit comments