Skip to content

Commit 42875af

Browse files
authored
Series: Test is not testing for zero length series (#1725)
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]
1 parent 149839f commit 42875af

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

exercises/practice/series/.meta/example.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class Series
22
def initialize(series)
3+
raise ArgumentError if series.length.zero?
34
@series = series
45
end
56
def slices(n)

exercises/practice/series/series_test.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,8 @@ def test_slice_length_cannot_be_negative
6868
def test_empty_series_is_invalid
6969
skip
7070
slice_string = ""
71-
series = Series.new(slice_string)
7271
assert_raises ArgumentError do
73-
series.slices(1)
72+
Series.new(slice_string)
7473
end
7574
end
7675
end

0 commit comments

Comments
 (0)