In the group_by enumerables exercise, the test_group_by_order_of_magnitude seems to be expecting something other than order of magnitude. I did some googling to figure out how to calculate order of magnitude (see the Wikipedia article) and in Ruby we can use Math.log10(X).floor for an approximation.
For example, as the Wikipedia article states, the order of magnitude of 1 is zero, not one:
It could it also make more sense to change the test names to something like test_group_by_number_of_digits if figuring out an order of magnitude calculation is more effort than intended.
In the group_by enumerables exercise, the
test_group_by_order_of_magnitude
seems to be expecting something other than order of magnitude. I did some googling to figure out how to calculate order of magnitude (see the Wikipedia article) and in Ruby we can useMath.log10(X).floor
for an approximation.For example, as the Wikipedia article states, the order of magnitude of 1 is zero, not one:
Below is a suggested change that adjusts the keys in
expected
by -1 (the test is the same in both group_by test files).It could it also make more sense to change the test names to something like
test_group_by_number_of_digits
if figuring out an order of magnitude calculation is more effort than intended.