Skip to content

Commit

Permalink
refactor {texdocs,tlpdb}_spec.rb: less regex matching
Browse files Browse the repository at this point in the history
  • Loading branch information
wtsnjp committed Aug 17, 2024
1 parent cb22b6c commit 6fec041
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions spec/search/texdocs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
13 changes: 7 additions & 6 deletions spec/search/tlpdb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand Down

0 comments on commit 6fec041

Please sign in to comment.