Skip to content

Commit

Permalink
specs for the new prompt_more feature
Browse files Browse the repository at this point in the history
  • Loading branch information
wtsnjp committed Feb 4, 2024
1 parent 84e4446 commit fa58d09
Showing 1 changed file with 100 additions and 31 deletions.
131 changes: 100 additions & 31 deletions spec/mode/list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,50 +23,119 @@
end
end

context "when RET is typed" do
context "in the interactive mode" do
before(:each) { run_texdoc "-vl", "texlive-en", interactive: true }
before(:each) { type "" }
before(:each) { stop_all_commands }

it "should view the first item in the list" do
first_item = stdout[/^ 1 (.*)$/, 1]
expect(stderr).to include(info_line "View command: #{mock_viewer} \"#{first_item}\"")
expect(last_command_started).to be_successfully_executed
context "when RET is typed" do
before(:each) { type "" }
before(:each) { stop_all_commands }

it "should view the first item in the list" do
first_item = stdout[/^ 1 (.*)$/, 1]
expect(stderr).to include(info_line "View command: #{mock_viewer} \"#{first_item}\"")
expect(last_command_started).to be_successfully_executed
end
end
end

context 'when "1" is typed' do
before(:each) { run_texdoc "-vl", "texlive-en", interactive: true }
before(:each) { type "1" }
before(:each) { stop_all_commands }
context 'when "1" is typed' do
before(:each) { type "1" }
before(:each) { stop_all_commands }

it "should view the first item in the list" do
first_item = stdout[/^ 1 (.*)$/, 1]
expect(stderr).to include(info_line "View command: #{mock_viewer} \"#{first_item}\"")
expect(last_command_started).to be_successfully_executed
it "should view the first item in the list" do
first_item = stdout[/^ 1 (.*)$/, 1]
expect(stderr).to include(info_line "View command: #{mock_viewer} \"#{first_item}\"")
expect(last_command_started).to be_successfully_executed
end
end
end

context 'when "2" is typed' do
before(:each) { run_texdoc "-vl", "texlive-en", interactive: true }
before(:each) { type "2" }
before(:each) { stop_all_commands }
context 'when "2" is typed' do
before(:each) { type "2" }
before(:each) { stop_all_commands }

it "should view the second item in the list" do
second_item = stdout[/^ 2 (.*)$/, 1]
expect(stderr).to include(info_line "View command: #{mock_viewer} \"#{second_item}\"")
expect(last_command_started).to be_successfully_executed
it "should view the second item in the list" do
second_item = stdout[/^ 2 (.*)$/, 1]
expect(stderr).to include(info_line "View command: #{mock_viewer} \"#{second_item}\"")
expect(last_command_started).to be_successfully_executed
end
end

context 'when "x" is typed' do
before(:each) { type "x" }
before(:each) { stop_all_commands }

it "should exit without viewing" do
expect(stderr).not_to include(info_line "View command: ")
expect(last_command_started).to be_successfully_executed
end
end
end

context 'when "x" is typed' do
before(:each) { run_texdoc "-vl", "texlive-en", interactive: true }
before(:each) { type "x" }
before(:each) { stop_all_commands }
context "in the interactive mode, if the list length is greater than max_lines" do
before(:each) { run_texdoc "-vl", "latex", interactive: true }

it 'should show the top 10 (`max_lines`) results' do
type ""
stop_all_commands

it "should exit without viewing" do
expect(stderr).not_to include(info_line "View command: ")
expect(stdout).to match(/\A\d+ results. Only the top 10 are shown below./)
expect(stdout).to match(/^ 1 (.*)$/)
expect(stdout).to match(/^10 (.*)$/)
expect(stdout).not_to match(/^11 (.*)$/)
expect(last_command_started).to be_successfully_executed
end

context "when RET is typed" do
before(:each) { type "" }
before(:each) { stop_all_commands }

it "should view the first item in the list" do
first_item = stdout[/^ 1 (.*)$/, 1]
expect(stderr).to include(info_line "View command: #{mock_viewer} \"#{first_item}\"")
expect(last_command_started).to be_successfully_executed
end
end

context 'when "1" is typed' do
before(:each) { type "1" }
before(:each) { stop_all_commands }

it "should view the first item in the list" do
first_item = stdout[/^ 1 (.*)$/, 1]
expect(stderr).to include(info_line "View command: #{mock_viewer} \"#{first_item}\"")
expect(last_command_started).to be_successfully_executed
end
end

context 'when "2" is typed' do
before(:each) { type "2" }
before(:each) { stop_all_commands }

it "should view the second item in the list" do
second_item = stdout[/^ 2 (.*)$/, 1]
expect(stderr).to include(info_line "View command: #{mock_viewer} \"#{second_item}\"")
expect(last_command_started).to be_successfully_executed
end
end

context 'when "S" is typed' do
before(:each) { type "S" }
before(:each) { type "" }
before(:each) { stop_all_commands }

it 'should show all results' do
expect(stdout).to include ("Enter number of file to view, RET to view 1, anything else to skip:")
expect(last_command_started).to be_successfully_executed
end
end

context 'when "x" is typed' do
before(:each) { type "x" }
before(:each) { stop_all_commands }

it "should exit without viewing" do
expect(stderr).not_to include(info_line "View command: ")
expect(last_command_started).to be_successfully_executed
end
end
end
end

0 comments on commit fa58d09

Please sign in to comment.