Skip to content

Commit

Permalink
Fixed broken spec
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyObtiva committed Jul 24, 2020
1 parent 571e48b commit 1dd881e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions lib/puts_debuggerer.rb
Expand Up @@ -74,7 +74,7 @@ def app_path=(path)
attr_reader :source_line_count

def source_line_count=(value)
@source_line_count = value.to_i || SOURCE_LINE_COUNT_DEFAULT
@source_line_count = value || SOURCE_LINE_COUNT_DEFAULT
end

# Header to include at the top of every print out.
Expand Down Expand Up @@ -578,12 +578,16 @@ def __caller_source_line__(caller_depth=0, source_line_count=nil, source_file=ni
f = File.new(source_file)
if f.respond_to?(:readline) # Opal Ruby Compatibility
source_lines = []
while f.lineno < source_line_number - 1 + source_line_count
file_line_number = f.lineno
file_line = f.readline
if file_line_number >= source_line_number - 1 && file_line_number < source_line_number - 1 + source_line_count
source_lines << file_line
begin
while f.lineno < source_line_number + source_line_count
file_line_number = f.lineno + 1
file_line = f.readline
if file_line_number >= source_line_number && file_line_number < source_line_number + source_line_count
source_lines << file_line
end
end
rescue EOFError
# Done
end
source_line = source_lines.join(' '*5)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/puts_debuggerer__exception_cases__spec.rb
Expand Up @@ -24,7 +24,7 @@
name = 'Robert'
PutsDebuggererInvoker.multi_line_dynamic_greeting_source_line_count(name)
output = $stdout.string
expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:43\n > pd \"Hello \" +\n name.to_s, source_line_count: 2\n => \"Hello Robert\"\n")
expect(output).to eq("[PD] #{puts_debuggerer_invoker_file}:43\n > pd \"Hello \" +\n name.to_s, source_line_count: 2\n => \"Hello Robert\"\n")
end
end
end

0 comments on commit 1dd881e

Please sign in to comment.