|
1 | 1 | require 'spec_helper'
|
| 2 | +require 'digest/md5' |
2 | 3 |
|
3 | 4 | RSpec.describe "Alias", :type => :aruba do
|
4 | 5 | include_context "messages"
|
5 | 6 | include_context "texmf"
|
6 | 7 |
|
7 |
| - let(:texdoc_cnf) { texmf_home / "texdoc/texdoc.cnf" } |
| 8 | + let(:test_texdoc_cnf) { texmf_home / "texdoc/texdoc.cnf" } |
8 | 9 |
|
9 | 10 | context "is set in texdoc.cnf" do
|
10 | 11 | let(:config_content) {
|
11 | 12 | <<~EOF
|
12 | 13 | alias testalias = texlive
|
13 | 14 | EOF
|
14 | 15 | }
|
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)) } |
17 | 21 |
|
18 | 22 | 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 } |
20 | 25 |
|
21 | 26 | 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)") |
26 | 31 | expect(last_command_started).to be_successfully_executed
|
27 | 32 | end
|
28 | 33 | end
|
29 | 34 |
|
30 | 35 | 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 } |
32 | 38 |
|
33 | 39 | 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)") |
38 | 44 | end
|
39 | 45 | end
|
40 | 46 | end
|
|
0 commit comments