Skip to content

Commit

Permalink
Remove question asked flag since not used
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexB52 committed Dec 11, 2024
1 parent 0b925f3 commit 29b7547
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 65 deletions.
36 changes: 11 additions & 25 deletions lib/retest/prompt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,21 @@ def initialize(input: nil, output: nil)
@question_asked = false
end

def question_asked?
@question_asked
end

def ask_which_test_to_use(path, files)
ask_question do
changed
notify_observers(:question)
options = options(files)
changed
notify_observers(:question)
options = options(files)

output.puts(<<~QUESTION)
We found few tests matching: #{path}
output.puts(<<~QUESTION)
We found few tests matching: #{path}
#{list_options(options.keys)}
#{list_options(options.keys)}
Which file do you want to use?
Enter the file number now:
QUESTION
output.print("> ")
options.values[input.gets.to_s.chomp.to_i]
end
Which file do you want to use?
Enter the file number now:
QUESTION
output.print("> ")
options.values[input.gets.to_s.chomp.to_i]
end

def puts(*args)
Expand All @@ -40,14 +34,6 @@ def read_output
output.tap(&:rewind).read
end

def ask_question
old_question_asked = @question_asked
@question_asked = true
yield
ensure
@question_asked = old_question_asked
end

private

def options(files, blank_option: 'none')
Expand Down
40 changes: 0 additions & 40 deletions test/retest/prompt_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,6 @@ def test_ask_which_test_to_use
EXPECTED
end

def test_question_asked_when_asking_question
files = %w(
test/models/taxation/holdings_test.rb
test/models/schedule/holdings_test.rb
test/models/holdings_test.rb
test/models/performance/holdings_test.rb
test/lib/csv_report/holdings_test.rb
)

rd, wr = IO.pipe

@subject.input = rd

th = Thread.new do
@subject.ask_which_test_to_use("app/models/valuation/holdings.rb", files)
end

wait_until { assert @subject.question_asked? }

wr.puts("1\n")

assert_equal "test/models/schedule/holdings_test.rb", th.value
refute @subject.question_asked?
ensure
rd.close
wr.close
end

def test_read_output
@subject.output.puts "hello world\n"

Expand All @@ -102,17 +74,5 @@ def test_observers_receive_correct_update_on_ask_which_test_to_use

assert_includes observer.notepad, MethodCall.new(name: :update, args: [:question])
end

def test_ask_question
refute @subject.question_asked?
@subject.ask_question do
assert @subject.question_asked?
end
refute @subject.question_asked?
end

def test_question_flag_when_asking_for_file

end
end
end

0 comments on commit 29b7547

Please sign in to comment.