Skip to content

Commit

Permalink
test diamonds: reduce checking (#206)
Browse files Browse the repository at this point in the history
GitHub: GH-188

Because csv file is too big (53,940 rows).

Before this change:

```console
$ time ruby test/run-test.rb -t DiamondsTest --verbose=important-only
Finished in 3.367821 seconds.
2 tests, 2 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0
notifications

real    0m4.179s
user    0m3.738s
sys     0m0.202s
```

After this change:

```console
$ time ruby test/run-test.rb -t DiamondsTest --verbose=important-only
Finished in 0.002048 seconds.
2 tests, 2 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0
notifications

real    0m0.551s
user    0m0.379s
sys     0m0.085s
```
  • Loading branch information
tikkss authored Sep 2, 2024
1 parent dd2e617 commit 9e20d34
Showing 1 changed file with 13 additions and 33 deletions.
46 changes: 13 additions & 33 deletions test/test-diamonds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,19 @@ def record(*args)
end

test("#each") do
records = @dataset.each.to_a
assert_equal([
53940,
{
carat: 0.23,
clarity: "SI2",
color: "E",
cut: "Ideal",
depth: 61.5,
price: 326,
table: 55.0,
x: 3.95,
y: 3.98,
z: 2.43,
},
{
carat: 0.75,
clarity: "SI2",
color: "D",
cut: "Ideal",
depth: 62.2,
price: 2757,
table: 55.0,
x: 5.83,
y: 5.87,
z: 3.64,
},
],
[
records.size,
records[0].to_h,
records[-1].to_h
])
assert_equal({
carat: 0.23,
clarity: "SI2",
color: "E",
cut: "Ideal",
depth: 61.5,
price: 326,
table: 55.0,
x: 3.95,
y: 3.98,
z: 2.43,
},
@dataset.each.next.to_h)
end

sub_test_case("#metadata") do
Expand Down

0 comments on commit 9e20d34

Please sign in to comment.