Skip to content

Commit

Permalink
Fix a typo (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jethrodaniel authored Dec 27, 2023
1 parent 11289a9 commit ecdb0d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/paco/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Paco
# @param [Integer] pos
def self.calculate(input:, pos:)
raise ArgumentError, "`pos` must be a non-negative integer" if pos < 0
raise ArgumentError, "`pos` is grater then input length" if pos > input.length
raise ArgumentError, "`pos` is greater then input length" if pos > input.length

lines = input[0..pos].lines
line = lines.empty? ? 1 : lines.length
Expand Down
10 changes: 8 additions & 2 deletions spec/paco/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@
end

it "raises an error when pos < 0" do
expect { index.calculate(input: input, pos: -1) }.to raise_error(ArgumentError)
expect { index.calculate(input: input, pos: -1) }.to raise_error(
ArgumentError,
"`pos` must be a non-negative integer"
)
end

it "raises an error when pos > input length" do
expect { index.calculate(input: input, pos: 1000) }.to raise_error(ArgumentError)
expect { index.calculate(input: input, pos: 1000) }.to raise_error(
ArgumentError,
"`pos` is greater then input length"
)
end
end

0 comments on commit ecdb0d2

Please sign in to comment.