From 6fec041ea8a141551c0e49f0da58a6d202d0cf79 Mon Sep 17 00:00:00 2001 From: Takuto Asakura Date: Sat, 17 Aug 2024 14:44:27 +0900 Subject: [PATCH] refactor {texdocs,tlpdb}_spec.rb: less regex matching --- spec/search/texdocs_spec.rb | 5 +++-- spec/search/tlpdb_spec.rb | 13 +++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/spec/search/texdocs_spec.rb b/spec/search/texdocs_spec.rb index 3cde67b..bb47529 100644 --- a/spec/search/texdocs_spec.rb +++ b/spec/search/texdocs_spec.rb @@ -58,18 +58,19 @@ RSpec.describe "Document search in texdocs", :type => :aruba do include_context "messages" + include_context "texmf" context "for a docfile name query" do let(:test_res_name) { "latex/babel/babel-code.pdf" } let(:test_res_hash) { "4abb904" } - let(:test_res_realpath) { Regexp.escape(normalize_path(test_res_name)) } + let(:test_res_realpath) { normalize_path(texmf_dist / "doc" / test_res_name) } let(:test_query) { "babel-code" } before(:each) { run_texdoc "-ddocfile", test_query } it "should find the document" do expect(stderr).to include(debug_line "search", "Searching documents for pattern \"#{test_query}\"") - expect(stderr).to match(/#{debug_line "search"} \(#{test_res_hash}\) File \S*#{test_res_realpath} found/) + expect(stderr).to include(debug_line "search", "(#{test_res_hash}) File #{test_res_realpath} found") expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) name: #{test_res_name}") expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) matches: #{test_query}") expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) sources: texdocs") diff --git a/spec/search/tlpdb_spec.rb b/spec/search/tlpdb_spec.rb index bb0859a..052bfad 100644 --- a/spec/search/tlpdb_spec.rb +++ b/spec/search/tlpdb_spec.rb @@ -2,18 +2,19 @@ RSpec.describe "Document search in tlpdb", :type => :aruba do include_context "messages" + include_context "texmf" context "for a runfile, tlp, and docfile name query" do let(:test_res_name) { "latex/babel/babel.pdf" } let(:test_res_hash) { "b26f92e" } - let(:test_res_realpath) { Regexp.escape(normalize_path(test_res_name)) } + let(:test_res_realpath) { normalize_path(texmf_dist / "doc" / test_res_name) } let(:test_query) { "babel" } before(:each) { run_texdoc "-ddocfile", test_query } it "should find the document from both tlpdb and texdocs" do expect(stderr).to include(debug_line "search", "Searching documents for pattern \"#{test_query}\"") - expect(stderr).to match(/#{debug_line "search"} \(#{test_res_hash}\) File \S*#{test_res_realpath} found/) + expect(stderr).to include(debug_line "search", "(#{test_res_hash}) File #{test_res_realpath} found") expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) name: #{test_res_name}") expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) matches: #{test_query}") expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) runtodoc: true") @@ -25,14 +26,14 @@ context "for a tlp and docfile name query" do let(:test_res_name) { "texmf-dist/doc/man/man1/dvipdfmx.man1.pdf" } let(:test_res_hash) { "e49c24d" } - let(:test_res_realpath) { Regexp.escape(normalize_path(test_res_name)) } + let(:test_res_realpath) { normalize_path(texmf_dist.parent / test_res_name) } let(:test_query) { "dvipdfmx" } before(:each) { run_texdoc "-ddocfile", test_query } it "should find the document from tlpdb" do expect(stderr).to include(debug_line "search", "Searching documents for pattern \"#{test_query}\"") - expect(stderr).to match(/#{debug_line "search"} \(#{test_res_hash}\) File \S*#{test_res_realpath} found/) + expect(stderr).to include(debug_line "search", "(#{test_res_hash}) File #{test_res_realpath} found") expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) name: #{test_res_name}") expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) matches: #{test_query}") expect(stderr).not_to include(debug_line "docfile", "(#{test_res_hash}) runtodoc: true") @@ -43,14 +44,14 @@ context "for a runfile and docfile name query" do let(:test_res_name) { "latex/tools/xspace.pdf" } let(:test_res_hash) { "9146ab6" } - let(:test_res_realpath) { Regexp.escape(normalize_path(test_res_name)) } + let(:test_res_realpath) { normalize_path(texmf_dist / "doc" / test_res_name) } let(:test_query) { "xspace" } before(:each) { run_texdoc "-ddocfile", test_query } it "should find the document from tlpdb" do expect(stderr).to include(debug_line "search", "Searching documents for pattern \"#{test_query}\"") - expect(stderr).to match(/#{debug_line "search"} \(#{test_res_hash}\) File \S*#{test_res_realpath} found/) + expect(stderr).to include(debug_line "search", "(#{test_res_hash}) File #{test_res_realpath} found") expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) name: #{test_res_name}") expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) matches: #{test_query}") expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) runtodoc: true")