Skip to content

Commit

Permalink
#141 test eva
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Sep 26, 2024
1 parent 1061273 commit 04a70ef
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
require 'rubygems'
require 'rake'

ENV['RACK_RUN'] = 'true'

task default: %i[test judges rubocop]

require 'rake/clean'
Expand Down
19 changes: 18 additions & 1 deletion test/pages/test_eva_summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,24 @@
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
# License:: MIT
class TestEvaSummary < Minitest::Test
def test_template
def test_template_long
xml = xslt(
'<xsl:apply-templates select="/fb/f"/>',
'
<fb>
<f>
<what>earned-value</what>
<ac>444</ac>
<ev>555</ev>
<pv>666</pv>
</f>
</fb>
'
)
assert(!xml.xpath('/p/text()').to_s.start_with?('Not enough data'), xml)
end

def test_template_short
xml = xslt(
'<xsl:apply-templates select="/fb/f"/>',
'
Expand Down
6 changes: 5 additions & 1 deletion test/test__helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def stub_github(url, body:, method: :get, status: 200, headers: { 'content-type'
stub_request(method, url).to_return(status:, body: body.to_json, headers:)
end

def fake_loog
ENV['RACK_RUN'] ? Loog::NULL : Loog::VERBOSE
end

def xslt(template, xml, vars = {})
Dir.mktmpdir do |dir|
xsl = File.join(dir, 'foo.xsl')
Expand All @@ -79,7 +83,7 @@ def xslt(template, xml, vars = {})
"-xsl:#{Shellwords.escape(xsl)}",
"-o:#{Shellwords.escape(output)}"
] + vars.map { |k, v| Shellwords.escape("#{k}=#{v}") },
log: Loog::NULL
log: fake_loog
)
Nokogiri::XML.parse(File.read(output))
end
Expand Down
4 changes: 2 additions & 2 deletions xsl/eva-summary.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:z="https://www.zerocracy.com" exclude-result-prefixes="xs z">
<xsl:template match="f[what='earned-value' and ac and ev and pv]" priority="1">
<xsl:template match="f[what='earned-value' and ac and ev and pv]" priority="2">
<xsl:text>AC: </xsl:text>
<xsl:value-of select="format-number(ac, '0')"/>
<xsl:text>, EV: </xsl:text>
Expand All @@ -36,7 +36,7 @@ SOFTWARE.
<xsl:copy-of select="z:index(ev div pv)"/>
<xsl:text>.</xsl:text>
</xsl:template>
<xsl:template match="f[what='earned-value']" priority="2">
<xsl:template match="f[what='earned-value']" priority="1">
<p class="darkred">
<xsl:text>Not enough data in the latest earned-value fact.</xsl:text>
</p>
Expand Down

0 comments on commit 04a70ef

Please sign in to comment.