Skip to content

Commit add562e

Browse files
committed
add spec/search/texdocs_spec; refactor alias_spec.rb
1 parent aca8b4d commit add562e

File tree

2 files changed

+42
-14
lines changed

2 files changed

+42
-14
lines changed

spec/search/alias_spec.rb

+19-13
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,46 @@
11
require 'spec_helper'
2+
require 'digest/md5'
23

34
RSpec.describe "Alias", :type => :aruba do
45
include_context "messages"
56
include_context "texmf"
67

7-
let(:texdoc_cnf) { texmf_home / "texdoc/texdoc.cnf" }
8+
let(:test_texdoc_cnf) { texmf_home / "texdoc/texdoc.cnf" }
89

910
context "is set in texdoc.cnf" do
1011
let(:config_content) {
1112
<<~EOF
1213
alias testalias = texlive
1314
EOF
1415
}
15-
before(:each) { File.write(texdoc_cnf, config_content) }
16-
let(:realpath) { Regexp.escape(normalize_path("texlive/texlive-en/texlive-en.pdf")) }
16+
before(:each) { File.write(test_texdoc_cnf, config_content) }
17+
18+
let(:test_res_name) { "texlive/texlive-en/texlive-en.pdf" }
19+
let(:test_res_hash) { Digest::MD5.hexdigest(test_res_name)[0, 7] }
20+
let(:test_res_realpath) { Regexp.escape(normalize_path(test_res_name)) }
1721

1822
context "and query the exact alias" do
19-
before(:each) { run_texdoc "-ddocfile", "testalias" }
23+
let(:test_query) { "testalias" }
24+
before(:each) { run_texdoc "-ddocfile", test_query }
2025

2126
it "should find aliased documents" do
22-
expect(stderr).to include(debug_line "search", 'Searching documents for pattern "testalias"')
23-
expect(stderr).to match(/texdoc debug-search: \(0da8ec4\) File \S*#{realpath} found/)
24-
expect(stderr).to include(debug_line "docfile", "(0da8ec4) name: texlive/texlive-en/texlive-en.pdf")
25-
expect(stderr).to include(debug_line "docfile", "(0da8ec4) matches: texlive (alias)")
27+
expect(stderr).to include(debug_line "search", "Searching documents for pattern \"#{test_query}\"")
28+
expect(stderr).to match(/#{debug_line "search"} \(#{test_res_hash}\) File \S*#{test_res_realpath} found/)
29+
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) name: #{test_res_name}")
30+
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) matches: texlive (alias)")
2631
expect(last_command_started).to be_successfully_executed
2732
end
2833
end
2934

3035
context "and query a misspelled alias" do
31-
before(:each) { run_texdoc "-M", "-ddocfile", "testaliases" }
36+
let(:test_query) { "testaliases" }
37+
before(:each) { run_texdoc "-M", "-ddocfile", test_query }
3238

3339
it "should not find aliased documents" do
34-
expect(stderr).to include(debug_line "search", 'Searching documents for pattern "testaliases"')
35-
expect(stderr).not_to match(/texdoc debug-search: \(0da8ec4\) File \S*#{realpath} found/)
36-
expect(stderr).not_to include(debug_line "docfile", "(0da8ec4) name: texlive/texlive-en/texlive-en.pdf")
37-
expect(stderr).not_to include(debug_line "docfile", "(0da8ec4) matches: texlive (alias)")
40+
expect(stderr).to include(debug_line "search", "Searching documents for pattern \"#{test_query}\"")
41+
expect(stderr).not_to match(/#{debug_line "search"} \(#{test_res_hash}\) File \S*#{test_res_realpath} found/)
42+
expect(stderr).not_to include(debug_line "docfile", "(#{test_res_hash}) name: #{test_res_name}")
43+
expect(stderr).not_to include(debug_line "docfile", "(#{test_res_hash}) matches: texlive (alias)")
3844
end
3945
end
4046
end

spec/search/texdocs_spec.rb

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'spec_helper'
2+
require 'digest/md5'
23

3-
RSpec.describe "TEXDOCS handling", :type => :aruba do
4+
RSpec.describe "Handling texdocs", :type => :aruba do
45
include_context "messages"
56
include_context "texmf"
67

@@ -55,3 +56,24 @@
5556
end
5657
end
5758
end
59+
60+
RSpec.describe "Document search in texdocs", :type => :aruba do
61+
include_context "messages"
62+
63+
context "for a docfile name query" do
64+
let(:test_res_name) { "latex/babel/babel-code.pdf" }
65+
let(:test_res_hash) { Digest::MD5.hexdigest(test_res_name)[0, 7] }
66+
let(:test_res_realpath) { Regexp.escape(normalize_path(test_res_name)) }
67+
68+
let(:test_query) { "babel-code" }
69+
before(:each) { run_texdoc "-ddocfile", test_query }
70+
71+
it "should find the documents" do
72+
expect(stderr).to include(debug_line "search", "Searching documents for pattern \"#{test_query}\"")
73+
expect(stderr).to match(/#{debug_line "search"} \(#{test_res_hash}\) File \S*#{test_res_realpath} found/)
74+
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) name: #{test_res_name}")
75+
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) matches: #{test_query}")
76+
expect(stderr).to include(debug_line "docfile", "(#{test_res_hash}) source: texdocs")
77+
end
78+
end
79+
end

0 commit comments

Comments
 (0)