From 1dcd462bc5920a77a1b251bbb6a2024ac1e37d8c Mon Sep 17 00:00:00 2001 From: KOTP Date: Thu, 31 Oct 2024 13:16:24 -0400 Subject: [PATCH] Series: Test is not testing for zero length series This test now raises if the series is 0 instead of of the slice slice size being larger than the series. This allows one to raise on normalization of user input, the series given, rather than incidentally having the slice size of 1 be larger than the series size from a zero length string. The example solution is updated to raise specifically for a zero length series, rather than the incidental raising when slices are asked for. Note: This should not invalidate current solutions, while allowing solutions that raise in `initialize` for the reason that the series is 0 length will now pass: No need to test current solutions: [no important files changed] --- exercises/practice/series/.meta/example.rb | 1 + exercises/practice/series/series_test.rb | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/practice/series/.meta/example.rb b/exercises/practice/series/.meta/example.rb index d93923d611..dfca6db15a 100644 --- a/exercises/practice/series/.meta/example.rb +++ b/exercises/practice/series/.meta/example.rb @@ -1,5 +1,6 @@ class Series def initialize(series) + raise ArgumentError if series.length.zero? @series = series end def slices(n) diff --git a/exercises/practice/series/series_test.rb b/exercises/practice/series/series_test.rb index 759b5c5288..f93e624068 100644 --- a/exercises/practice/series/series_test.rb +++ b/exercises/practice/series/series_test.rb @@ -68,9 +68,8 @@ def test_slice_length_cannot_be_negative def test_empty_series_is_invalid skip slice_string = "" - series = Series.new(slice_string) assert_raises ArgumentError do - series.slices(1) + Series.new(slice_string) end end end