Skip to content

Commit

Permalink
Fix FrozenError when using interactive environment selector
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbrictson committed Jun 22, 2024
1 parent 1c055f5 commit 1ccfcdf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tomo/console/key_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class KeyReader
extend Forwardable

def initialize(input=$stdin)
@buffer = ""
@buffer = +""
@input = input
end

Expand Down
25 changes: 25 additions & 0 deletions test/tomo/console/key_reader_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require "test_helper"
require "stringio"

class Tomo::Console
class KeyReaderTest < Minitest::Test
def setup
@input = StringIO.new
@input.define_singleton_method(:raw) do |&block|
block.call
end
end

def test_reads_a_single_keystroke
@input << "h"
@input.rewind

key_reader = KeyReader.new(@input)
char = key_reader.next

assert_equal("h", char)
end
end
end

0 comments on commit 1ccfcdf

Please sign in to comment.