From cb22b6c35233440e3ab262b87406b28908dd1869 Mon Sep 17 00:00:00 2001 From: Takuto Asakura Date: Tue, 13 Aug 2024 23:13:52 +0900 Subject: [PATCH] add spec/score/order_spec.rb --- spec/score/order_spec.rb | 36 +++++++++++++++++++ spec/support/shared_contexts/texmf_context.rb | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 spec/score/order_spec.rb diff --git a/spec/score/order_spec.rb b/spec/score/order_spec.rb new file mode 100644 index 0000000..b9cecdf --- /dev/null +++ b/spec/score/order_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +RSpec.describe "Document order in the result", :type => :aruba do + include_context "messages" + include_context "texmf" + + context "for documents with different scores" do + before(:each) { run_texdoc "-lM", "babel" } + + let(:res_list_head) do + <<~EXPECTED + babel\t7.0\t#{normalize_path(texmf_dist / "doc/latex/babel/babel.pdf")}\t\tUser guide + babel\t4.0\t#{normalize_path(texmf_dist / "doc/latex/babel/babel-code.pdf")}\t\tCode documentation + EXPECTED + end + + it "should be ordered by the scores" do + expect(stdout).to start_with(res_list_head) + end + end + + context "for documents with the same scores and different extentions" do + before(:each) { run_texdoc "-lM", "texlive-en" } + + let(:res_list_head) do + <<~EXPECTED + texlive-en\t10.0\t#{normalize_path(texmf_dist / "doc/texlive/texlive-en/texlive-en.pdf")}\t\t + texlive-en\t10.0\t#{normalize_path(texmf_dist / "doc/texlive/texlive-en/texlive-en.html")}\t\t + EXPECTED + end + + it "should be ordered by the extention position" do + expect(stdout).to start_with(res_list_head) + end + end +end diff --git a/spec/support/shared_contexts/texmf_context.rb b/spec/support/shared_contexts/texmf_context.rb index 07c3ff5..1f24543 100644 --- a/spec/support/shared_contexts/texmf_context.rb +++ b/spec/support/shared_contexts/texmf_context.rb @@ -7,7 +7,7 @@ let(:ps_texmf_dist) { SpecHelplers::Texdoc::PS_TEXMF_DIST } # the only real TEXMF tree - let(:texmf_dist) { `kpsewhich --var-value TEXMFDIST`.chomp } + let(:texmf_dist) { Pathname(`kpsewhich --var-value TEXMFDIST`.chomp) } # link to texlive.tlpdb let(:ps_tlpdb) { SpecHelplers::Texdoc::REPO_TEXLIVE_TLPDB }