From 437111499e6ade6e5eae11b8d3755eb8ab93bfaf Mon Sep 17 00:00:00 2001 From: Takuto Asakura Date: Mon, 12 Aug 2024 19:28:53 +0900 Subject: [PATCH] add spec/search/tlpdb_spec.rb; update texdocs_spec.rb --- spec/search/texdocs_spec.rb | 7 ++--- spec/search/tlpdb_spec.rb | 60 +++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 spec/search/tlpdb_spec.rb diff --git a/spec/search/texdocs_spec.rb b/spec/search/texdocs_spec.rb index a7e43fc..1d662d0 100644 --- a/spec/search/texdocs_spec.rb +++ b/spec/search/texdocs_spec.rb @@ -1,5 +1,4 @@ require 'spec_helper' -require 'digest/md5' RSpec.describe "Handling texdocs", :type => :aruba do include_context "messages" @@ -62,18 +61,18 @@ context "for a docfile name query" do let(:test_res_name) { "latex/babel/babel-code.pdf" } - let(:test_res_hash) { Digest::MD5.hexdigest(test_res_name)[0, 7] } + let(:test_res_hash) { "4abb904" } let(:test_res_realpath) { Regexp.escape(normalize_path(test_res_name)) } let(:test_query) { "babel-code" } before(:each) { run_texdoc "-ddocfile", test_query } - it "should find the documents" do + 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 "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}) source: texdocs") + expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) sources: texdocs") end end end diff --git a/spec/search/tlpdb_spec.rb b/spec/search/tlpdb_spec.rb new file mode 100644 index 0000000..bb0859a --- /dev/null +++ b/spec/search/tlpdb_spec.rb @@ -0,0 +1,60 @@ +require 'spec_helper' + +RSpec.describe "Document search in tlpdb", :type => :aruba do + include_context "messages" + + 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_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 "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") + expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) tlptodoc: true") + expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) sources: tlpdb, texdocs") + end + end + + 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_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 "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") + expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) tlptodoc: true") + end + end + + 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_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 "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") + expect(stderr).not_to include(debug_line "docfile", "(#{test_res_hash}) tlptodoc: true") + end + end +end