Skip to content

Commit

Permalink
Mark abstention votes more clearly
Browse files Browse the repository at this point in the history
  • Loading branch information
hbiede committed Apr 12, 2024
1 parent 7723c04 commit fa3bc5e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions tests/vote_parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -502,22 +502,22 @@ def test_ballot_entry_string
def test_abstention_count_string
assert_equal('', OutputPrinter.abstention_count_string(1, 2))
assert_equal('', OutputPrinter.abstention_count_string(0, 1))
assert_equal("\t Abstained: 1 vote\n", OutputPrinter.abstention_count_string(10, 9))
assert_equal("\t Abstained: 91 votes\n", OutputPrinter.abstention_count_string(100, 9))
assert_equal("\t Abstained: 1091 votes\n", OutputPrinter.abstention_count_string(1100, 9))
assert_equal("\t [Abstained]: 1 vote\n", OutputPrinter.abstention_count_string(10, 9))
assert_equal("\t [Abstained]: 91 votes\n", OutputPrinter.abstention_count_string(100, 9))
assert_equal("\t [Abstained]: 1091 votes\n", OutputPrinter.abstention_count_string(1100, 9))
end

def test_position_report_totals
assert_equal(
"\t Abstained: 1 vote\n-------------------------------------------------\n\t Total: 193 votes\n\n",
"\t [Abstained]: 1 vote\n-------------------------------------------------\n\t Total: 193 votes\n\n",
OutputPrinter.position_report_totals(193, 192)
)
assert_equal(
"\t Abstained: 100 votes\n-------------------------------------------------\n\t Total: 193 votes\n\n",
"\t [Abstained]: 100 votes\n-------------------------------------------------\n\t Total: 193 votes\n\n",
OutputPrinter.position_report_totals(193, 93)
)
assert_equal(
"\t Abstained: 1 vote\n-------------------------------------------------\n\t Total: 1 vote\n\n",
"\t [Abstained]: 1 vote\n-------------------------------------------------\n\t Total: 1 vote\n\n",
OutputPrinter.position_report_totals(1, 0)
)
assert_equal(
Expand All @@ -539,7 +539,7 @@ def test_position_report_indiv

expected = "\t*AVote4: 4 votes (66.67%)\n" +
"\t AVote3: 1 vote (16.67%)\n" +
"\t Abstained: 1 vote\n" +
"\t [Abstained]: 1 vote\n" +
"-------------------------------------------------\n" +
"\t Total: 6 votes\n\n"
assert_equal(expected, result)
Expand All @@ -564,7 +564,7 @@ def test_position_report_indiv

expected = "\t AVote4: 4 votes (0.40%)\n" +
"\t AVote3: 2 votes (0.20%)\n" +
"\t Abstained: 994 votes\n" +
"\t [Abstained]: 994 votes\n" +
"-------------------------------------------------\n" +
"\t Total: 1000 votes\n\n"
assert_equal(expected, result)
Expand All @@ -577,7 +577,7 @@ def test_position_report_indiv

expected = "\t*AVote4: 600 votes (60.00%)\n" +
"\t AVote3: 2 votes (0.20%)\n" +
"\t Abstained: 398 votes\n" +
"\t [Abstained]: 398 votes\n" +
"-------------------------------------------------\n" +
"\t Total: 1000 votes\n\n"
assert_equal(expected, result)
Expand Down Expand Up @@ -631,7 +631,7 @@ def test_position_report
"President\n" +
"\t*AVote4: 60 votes (60.00%)\n" +
"\t AVote3: 20 votes (20.00%)\n" +
"\t Abstained: 20 votes\n" +
"\t [Abstained]: 20 votes\n" +
"-------------------------------------------------\n" +
"\t Total: 100 votes",
OutputPrinter.position_report(
Expand All @@ -645,7 +645,7 @@ def test_position_report
"President (No Majority)\n" +
"\t AVote3: 20 votes (20.00%)\n" +
"\t AVote4: 20 votes (20.00%)\n" +
"\t Abstained: 60 votes\n" +
"\t [Abstained]: 60 votes\n" +
"-------------------------------------------------\n" +
"\t Total: 100 votes",
OutputPrinter.position_report(
Expand All @@ -660,7 +660,7 @@ def test_position_report
"\t AVote4: 21 votes (21.00%)\n" +
"\t AVote2: 20 votes (20.00%)\n" +
"\t AVote3: 20 votes (20.00%)\n" +
"\t Abstained: 39 votes\n" +
"\t [Abstained]: 39 votes\n" +
"-------------------------------------------------\n" +
"\t Total: 100 votes",
OutputPrinter.position_report(
Expand Down Expand Up @@ -691,7 +691,7 @@ def test_vote_report
"\t Total: 6 votes\n\n\n" +
"Secretary (No Majority)\n" +
"\t Thomas Jefferson: 3 votes (50.00%)\n" +
"\t Abstained: 3 votes\n" +
"\t [Abstained]: 3 votes\n" +
"-------------------------------------------------\n" +
"\t Total: 6 votes\n\n\n" +
"Treasurer (No Majority)\n" +
Expand Down
4 changes: 2 additions & 2 deletions vote_parser.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

# Author: Hundter Biede (hbiede.com)
# Version: 1.4
# Version: 1.4.1
# License: MIT

require 'csv'
Expand Down Expand Up @@ -212,7 +212,7 @@ def self.abstention_count_string(vote_count, position_vote_count)
abstained = vote_count - position_vote_count
if abstained.positive?
format("\t %<Title>-20s %<AbsVotes>4d vote%<S>s\n",
Title: 'Abstained:', AbsVotes: abstained,
Title: '[Abstained]:', AbsVotes: abstained,
S: abstained == 1 ? '' : 's')
else
''
Expand Down

0 comments on commit fa3bc5e

Please sign in to comment.