From ee7298565d879127a193ef73f7e9351d159449d6 Mon Sep 17 00:00:00 2001 From: Matt J Cloyd Date: Mon, 10 Jun 2024 13:53:58 -0400 Subject: [PATCH] Upgrade Ruby and switch to Standard Ruby --- .github/workflows/main.yml | 6 +- Gemfile | 10 +-- Gemfile.lock | 62 +++++++++----- Rakefile | 2 +- lib/markdownify.rb | 38 ++++----- lib/validate.rb | 68 +++++++-------- test/fixtures.rb | 167 +++++++++++++++---------------------- test/markdownify_test.rb | 22 ++--- test/test_helper.rb | 4 +- test/validate_test.rb | 109 ++++++++++++------------ 10 files changed, 240 insertions(+), 248 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 88361da..7273688 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,17 +24,17 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - + - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7.3 + ruby-version: 3.3 bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Run linting and unit tests run: | gem install bundler bundle install --jobs 4 --retry 3 - bundle exec rubocop -c .rubocop.yml + bundle exec standardrb bundle exec rake test - name: Validate the glossary diff --git a/Gemfile b/Gemfile index 898da09..3582a2a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ -source 'https://rubygems.org' +source "https://rubygems.org" -ruby '~> 2.7' +ruby "~> 3" -gem 'minitest-reporters' -gem 'rake' -gem 'rubocop', '~> 1.25', require: false +gem "minitest-reporters" +gem "rake" +gem "standard" diff --git a/Gemfile.lock b/Gemfile.lock index 2e0b66d..8815817 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,33 +3,57 @@ GEM specs: ansi (1.5.0) ast (2.4.2) - builder (3.2.4) - minitest (5.15.0) - minitest-reporters (1.5.0) + builder (3.3.0) + json (2.7.2) + language_server-protocol (3.17.0.3) + lint_roller (1.1.0) + minitest (5.23.1) + minitest-reporters (1.6.1) ansi builder minitest (>= 5.0) ruby-progressbar - parallel (1.21.0) - parser (3.1.0.0) + parallel (1.24.0) + parser (3.3.2.0) ast (~> 2.4.1) + racc + racc (1.8.0) rainbow (3.1.1) - rake (13.0.6) - regexp_parser (2.2.0) - rexml (3.2.5) - rubocop (1.25.1) + rake (13.2.1) + regexp_parser (2.9.2) + rexml (3.2.8) + strscan (>= 3.0.9) + rubocop (1.63.5) + json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.15.1, < 2.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.15.1) - parser (>= 3.0.1.1) - ruby-progressbar (1.11.0) - unicode-display_width (2.1.0) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + rubocop-performance (1.21.0) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + ruby-progressbar (1.13.0) + standard (1.36.0) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.63.0) + standard-custom (~> 1.0.0) + standard-performance (~> 1.4) + standard-custom (1.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.50) + standard-performance (1.4.0) + lint_roller (~> 1.1) + rubocop-performance (~> 1.21.0) + strscan (3.1.0) + unicode-display_width (2.5.0) PLATFORMS ruby @@ -37,10 +61,10 @@ PLATFORMS DEPENDENCIES minitest-reporters rake - rubocop (~> 1.25) + standard RUBY VERSION - ruby 2.7.3p183 + ruby 3.2.3p157 BUNDLED WITH 2.1.4 diff --git a/Rakefile b/Rakefile index a113989..0049331 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,4 @@ task default: :test task :test do - Dir.glob('./test/*_test.rb').each { |file| require file } + Dir.glob("./test/*_test.rb").each { |file| require file } end diff --git a/lib/markdownify.rb b/lib/markdownify.rb index 27c6706..79a7be7 100644 --- a/lib/markdownify.rb +++ b/lib/markdownify.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true # Thanks https://avdi.codes/recursively-symbolize-keys/ -require 'yaml' -require './lib/common' -require './lib/validate' +require "yaml" +require "./lib/common" +require "./lib/validate" # Turn a validated glossary into a linked Markdown file class Markdownify @@ -12,23 +12,23 @@ class Markdownify attr_reader :data, :path, :output def initialize(path = nil, outpath = nil) - @path = path || './glossary.yml' - @output = outpath || './glossary.md' + @path = path || "./glossary.yml" + @output = outpath || "./glossary.md" @data = sort_data( symbolize_keys( - YAML.load_file(@path) + YAML.load_file(@path, aliases: true) ) ) end def perform - File.open(output, 'w') { |file| file << _perform } + File.open(output, "w") { |file| file << _perform } puts "\nSuccess! Check out your file at #{output}" end def _perform before_perform - str = '' + str = "" str += "### Acronyms & Initialisms\n\n" str += acronym_content str += "\n\n" @@ -38,11 +38,11 @@ def _perform end def acronym_content - str = '' + str = "" str += "| | |\n|-|-|\n" # table header build_tags_by_letter.sort.map do |letter, tags| str += "| #{letter} | " - str += "#{tags.join(' • ')} |" + str += "#{tags.join(" • ")} |" str += "\n" end str @@ -54,13 +54,13 @@ def build_tags_by_letter tag = tag_for_acronym(key, values) next if tag.nil? - results[key.to_s.chars.first.upcase] << tag + results[key.to_s[0].upcase] << tag end results end def tag_for_acronym(key, values) - case Array(values[:term]).count + case Array(values[:term]).size when 0 nil when 1 @@ -79,7 +79,7 @@ def tag_for_single_term(key, values) def tag_for_multiple_terms(key, values) term_links = values[:term].map.with_index do |term, i| "[(#{i + 1})](#{goto term})" - end.join(' ') + end.join(" ") <<~TAG #{key} #{term_links} TAG @@ -92,7 +92,7 @@ def definition_content end def build_definition(key, values) - str = '' + str = "" str += "**#{anchor(key)}#{self_link(key)}**" str += (acronym?(key) ? " (#{acronym_for(key).first}) \\\n" : " \\\n") str += description_content(values) @@ -117,7 +117,7 @@ def description_content(values) def overloaded_acronym?(key) if acronym?(key) _, values = acronym_for(key) - Array(values[:term]).count > 1 + Array(values[:term]).size > 1 else false end @@ -178,7 +178,7 @@ def anchor(key) end def slug(key) - key.to_s.downcase.gsub(/\s+/, '-') + key.to_s.downcase.gsub(/\s+/, "-") end private @@ -193,12 +193,12 @@ def sort_data(data) data[:entries].each do |entry| key, values = entry case values[:type] - when 'acronym' + when "acronym" acronyms[key] = values - when 'term' + when "term" terms[key] = values end end - { acronyms: acronyms, terms: terms } + {acronyms: acronyms, terms: terms} end end diff --git a/lib/validate.rb b/lib/validate.rb index 75f4346..13034c1 100755 --- a/lib/validate.rb +++ b/lib/validate.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require 'yaml' -require './lib/common' +require "yaml" +require "./lib/common" # @todo Acronyms must reference a term # @todo Cross-references are set as arrays @@ -14,9 +14,9 @@ class GlossaryValidator # @param path [String | nil] path to glossary file def initialize(path: nil) - @path = path || './glossary.yml' + @path = path || "./glossary.yml" @key = :entries - @data = symbolize_keys(YAML.load_file(@path)) + @data = symbolize_keys(YAML.load_file(@path, aliases: true)) # Minimally assert that the key is present # @todo: Make a better error message @data.fetch(@key) @@ -78,9 +78,9 @@ def validate(data) key = data.keys.first values = data.values.first case values[:type] - when 'term' + when "term" validate_term(data) - when 'acronym' + when "acronym" validate_acronym(data) else raise EntryTypeError, key @@ -106,9 +106,9 @@ def validate_term(term_data) key, values, %i[type - description - longform - cross_references] + description + longform + cross_references] ) true end @@ -137,7 +137,7 @@ def validate_term_crossreference_is_term(key, values) Array(values[:cross_references]).each do |crossref| crossref_entry = context.fetch(crossref.to_sym) case crossref_entry.fetch(:type) - when 'term' + when "term" # NO OP else raise CrossreferencesAcronymError.new(key, crossref, crossref_entry[:term]) @@ -161,11 +161,11 @@ def validate_acronym(acronym_data) def validate_term_defined(key, values) case values[:term].class.to_s - when 'String' + when "String" check_term_defined(values[:term]) - when 'Array' + when "Array" check_term_defined(values[:term]) - when 'NilClass' + when "NilClass" raise MissingTermError, key else raise MissingTermError, key @@ -189,9 +189,9 @@ def validate_acronym_term_exists(key, values) raise TermNotFoundError.new(key, term) unless context[term.to_sym] case context[term.to_sym][:type] - when 'acronym' + when "acronym" raise AcronymReferenceError.new(key, term) - when 'term' + when "term" # NO OP else raise EntryTypeError, term @@ -237,7 +237,7 @@ class MissingTermError < StandardError def initialize(key) @key = key - @term = key.to_s.split('').map { |letter| "#{letter}____ " }.join + @term = key.to_s.chars.map { |letter| "#{letter}____ " }.join super(message) end @@ -245,7 +245,7 @@ def message <<~ERR - The acronym \"#{key}\" doesn't define a related term! + The acronym "#{key}" doesn't define a related term! How can a reader know what your acronym means? @@ -279,17 +279,17 @@ def initialize(key, missing_term, crossref: false) end def message - noun = crossref ? 'term' : 'acronym' - verbs = crossref ? 'cross-references' : 'defines' + noun = crossref ? "term" : "acronym" + verbs = crossref ? "cross-references" : "defines" <<~ERR - The #{noun} \"#{key}\" #{verbs} the term \"#{missing_term}\", + The #{noun} "#{key}" #{verbs} the term "#{missing_term}", but I cannot find that term anywhere in the glossary. How can I know what term to link to? - Add an entry for \"#{missing_term}\", like: + Add an entry for "#{missing_term}", like: #{missing_term}: type: term @@ -317,12 +317,12 @@ def message <<~ERR - The term \"#{key}\" cross-references the acronym - \"#{crossref}\". Terms should cross-reference other + The term "#{key}" cross-references the acronym + "#{crossref}". Terms should cross-reference other terms instead of acronyms. - Should \"#{key}\" refer to \"#{crossref_term}\" instead - of \"#{crossref}\"? + Should "#{key}" refer to "#{crossref_term}" instead + of "#{crossref}"? ERR end end @@ -340,7 +340,7 @@ def message <<~ERR - The term \"#{key}\" does not have a description. + The term "#{key}" does not have a description. How can a reader know what this term means? @@ -376,9 +376,9 @@ def message <<~ERR - Your entry \"#{key}\" defines the following attributes (a.k.a. "keys"): + Your entry "#{key}" defines the following attributes (a.k.a. "keys"): - #{extra_keys.join(', ')} + #{extra_keys.join(", ")} These attributes aren't needed. Please delete them! ERR @@ -399,11 +399,11 @@ def message <<~ERR - Your acronym "#{key}" refers to another acronym: \"#{points_to}\". + Your acronym "#{key}" refers to another acronym: "#{points_to}". That doesn't make sense to me! - Please link your acronym to an entry that has a type of \"term\". Like this: + Please link your acronym to an entry that has a type of "term". Like this: #{key}: type: acronym @@ -431,13 +431,13 @@ def probable_type # If it's all uppercase and shorter than 10 characters, # it's probably an acronym if (key_str <=> key_str.upcase).zero? && key_str.length < 10 - 'acronym' + "acronym" else - 'term' + "term" end - rescue StandardError + rescue # Ignore all errors and default to "term" if there's an issue. - 'term' + "term" end def message diff --git a/test/fixtures.rb b/test/fixtures.rb index 2594810..61b3974 100644 --- a/test/fixtures.rb +++ b/test/fixtures.rb @@ -8,60 +8,48 @@ module Fixtures # ACRONYMS : VALID def valid_acronym - { FIDO: - { type: 'acronym', - term: 'Federal Interagency Databases Online' - } - } + {FIDO: + {type: "acronym", + term: "Federal Interagency Databases Online"}} end def valid_acronym_multi - { POP: - { type: 'acronym', - term: - ['Period of performance', - 'Procurement Operating Procedure'] - } - } + {POP: + {type: "acronym", + term: + ["Period of performance", + "Procurement Operating Procedure"]}} end # ACRONYMS : INVALID def invalid_acronym_no_type - { FIDO: - { term: 'Federal Interagency Databases Online' } - } + {FIDO: + {term: "Federal Interagency Databases Online"}} end def invalid_acronym_no_term - { FIDO: - { type: 'acronym' } - } + {FIDO: + {type: "acronym"}} end def invalid_acronym_null_term - { FIDO: - { type: 'acronym', - term: nil - } - } + {FIDO: + {type: "acronym", + term: nil}} end def invalid_acronym_extra_keys - { FIDO: - { type: 'acronym', - term: 'Federal Interagency Databases Online', - longform: 'hey' - } - } + {FIDO: + {type: "acronym", + term: "Federal Interagency Databases Online", + longform: "hey"}} end def invalid_acronym_refers_to_acronym - { FIDO: - { type: 'acronym', - term: 'ODIF' - } - } + {FIDO: + {type: "acronym", + term: "ODIF"}} end # @@ -71,57 +59,47 @@ def invalid_acronym_refers_to_acronym # TERMS : VALID def valid_term - { "Federal Interagency Databases Online": - { type: 'term', - description: 'Fido.gov is an internet location for finding information related to federal interagency databases.', - longform: 'An even more expanded version of the term.' - } - } + {"Federal Interagency Databases Online": + {type: "term", + description: "Fido.gov is an internet location for finding information related to federal interagency databases.", + longform: "An even more expanded version of the term."}} end def valid_term_null_desc - { "Federal Interagency Databases Online": - { type: 'term', - description: nil - } - } + {"Federal Interagency Databases Online": + {type: "term", + description: nil}} end def valid_term_pop1 { "Period of performance": - { type: 'term', - description: 'Description for period of performance' - } + {type: "term", + description: "Description for period of performance"} } end def valid_term_pop2 { "Procurement Operating Procedure": - { type: 'term', - description: 'Description for procurement operating procedure' - } + {type: "term", + description: "Description for procurement operating procedure"} } end def valid_term_no_crossref - { "Federal Interagency Databases Online": - { type: 'term', - description: 'Fido.gov is an internet location for finding information related to federal interagency databases.' - } - } + {"Federal Interagency Databases Online": + {type: "term", + description: "Fido.gov is an internet location for finding information related to federal interagency databases."}} end def valid_term_matching_crossrefs - { "Federal Interagency Databases Online": - { type: 'term', - description: 'Fido.gov is an internet location for finding information related to federal interagency databases.', - cross_references: - ['Period of performance', - 'Procurement Operating Procedure'] - } - } + {"Federal Interagency Databases Online": + {type: "term", + description: "Fido.gov is an internet location for finding information related to federal interagency databases.", + cross_references: + ["Period of performance", + "Procurement Operating Procedure"]}} end # TERMS : INVALID @@ -131,43 +109,36 @@ def invalid_term end def invalid_term_no_desc - { "Federal Interagency Databases Online": - { type: 'term' } - } + {"Federal Interagency Databases Online": + {type: "term"}} end def invalid_term_mismatched_crossrefs - { "Federal Interagency Databases Online": - { type: 'term', - description: 'Fido.gov is an internet location for finding information related to federal interagency databases.', - cross_references: + {"Federal Interagency Databases Online": + {type: "term", + description: "Fido.gov is an internet location for finding information related to federal interagency databases.", + cross_references: [ - 'Period of performance', - 'Not a match' - ] - } - } + "Period of performance", + "Not a match" + ]}} end def invalid_term_crossrefs_acronym - { "A term in the glossary": - { type: 'term', - description: "This is a term that appears in the glossary and its description written here so people know it's just a term.", - cross_references: + {"A term in the glossary": + {type: "term", + description: "This is a term that appears in the glossary and its description written here so people know it's just a term.", + cross_references: [ - 'ACRO' - ] - } - } + "ACRO" + ]}} end def invalid_term_extra_keys - { "Federal Interagency Databases Online": - { type: 'term', - description: 'Fido.gov is an internet location for finding information related to federal interagency databases.', - has_extra_key: 'Yes' - } - } + {"Federal Interagency Databases Online": + {type: "term", + description: "Fido.gov is an internet location for finding information related to federal interagency databases.", + has_extra_key: "Yes"}} end # @@ -191,18 +162,14 @@ def context_matching_crossrefs end def context_for_invalid_acronym_refers_to_acronym - { ODIF: - { type: 'acronym', - term: 'Online Database of Interagency Federation' - } - } + {ODIF: + {type: "acronym", + term: "Online Database of Interagency Federation"}} end def context_term_cross_references_acronym - { ACRO: - { type: 'acronym', - term: 'Letters That Stand For Words' - } - } + {ACRO: + {type: "acronym", + term: "Letters That Stand For Words"}} end end diff --git a/test/markdownify_test.rb b/test/markdownify_test.rb index 07173fc..3fd1e60 100644 --- a/test/markdownify_test.rb +++ b/test/markdownify_test.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require './test/test_helper' -require './lib/markdownify' +require "./test/test_helper" +require "./lib/markdownify" describe Markdownify do - describe 'with a valid glossary.yml' do - it 'renders markdown' do - subject = Markdownify.new('./test/test_glossary.yml') + describe "with a valid glossary.yml" do + it "renders markdown" do + subject = Markdownify.new("./test/test_glossary.yml") assert_equal valid_markdown, subject._perform, highlight: true end end @@ -18,16 +18,16 @@ def valid_markdown | | | |-|-| - | F | [FEMA](#federal-emergency-management-agency) • [FIDO](#federal-interagency-databases-online) | - | P | POP [(1)](#period-of-performance) [(2)](#procurement-operating-procedure) | + | F | [FEMA](#federal-emergency-management-agency) • [FIDO](#federal-interagency-databases-online) | + | P | POP [(1)](#period-of-performance) [(2)](#procurement-operating-procedure) | ### Terms & Definitions - **[Federal Emergency Management Agency](#federal-emergency-management-agency)** (FEMA) \\ + **[Federal Emergency Management Agency](#federal-emergency-management-agency)** (FEMA) \\ _No definition provided._ - **[Federal Interagency Databases Online](#federal-interagency-databases-online)** (FIDO) \\ + **[Federal Interagency Databases Online](#federal-interagency-databases-online)** (FIDO) \\ Fido.gov is an internet location for finding information related to federal interagency databases. Cross-references: @@ -35,12 +35,12 @@ def valid_markdown - [Period of performance](#period-of-performance) - [Procurement Operating Procedure](#procurement-operating-procedure) - **[Period of performance](#period-of-performance)** (POP) \\ + **[Period of performance](#period-of-performance)** (POP) \\ Description for period of performance _Not the definition you were looking for?_ [Back to POP](#acronym-POP) - **[Procurement Operating Procedure](#procurement-operating-procedure)** (POP) \\ + **[Procurement Operating Procedure](#procurement-operating-procedure)** (POP) \\ Description for procurement operating procedure _Not the definition you were looking for?_ [Back to POP](#acronym-POP) diff --git a/test/test_helper.rb b/test/test_helper.rb index 5e01e9f..0cff7f4 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'minitest/autorun' -require 'minitest/reporters' +require "minitest/autorun" +require "minitest/reporters" Minitest::Reporters.use! diff --git a/test/validate_test.rb b/test/validate_test.rb index 518eb59..91931c5 100644 --- a/test/validate_test.rb +++ b/test/validate_test.rb @@ -1,130 +1,131 @@ # frozen_string_literal: true -require './test/test_helper' -require './lib/validate' -require './test/fixtures' - -include Fixtures +require "./test/test_helper" +require "./lib/validate" +require "./test/fixtures" describe GlossaryValidator do - describe 'with a valid glossary' do - it 'raises no errors' do - subject = GlossaryValidator.new(path: './test/test_glossary.yml') + include Fixtures + + describe "with a valid glossary" do + it "raises no errors" do + subject = GlossaryValidator.new(path: "./test/test_glossary.yml") assert subject.perform end end - describe 'with a glossary containing duplicate entries' do - it 'raises an error' do - subject = GlossaryValidator.new(path: './test/test_glossary_dupe.yml') + describe "with a glossary containing duplicate entries" do + it "raises an error" do + subject = GlossaryValidator.new(path: "./test/test_glossary_dupe.yml") assert_raises(DuplicateKeyError) { subject.perform } end end end describe EntryValidator do - describe 'with a malformed entry' do - it 'errors' do + include Fixtures + describe "with a malformed entry" do + it "errors" do subject = EntryValidator.new({}) - assert_raises(ArgumentError) { subject.validate({ a: 1, b: 2 }) } + assert_raises(ArgumentError) { subject.validate({a: 1, b: 2}) } end end - describe 'term' do - describe 'with a valid term' do - it 'is valid' do + describe "term" do + describe "with a valid term" do + it "is valid" do subject = EntryValidator.new({}) assert_equal true, subject.validate(valid_term) end end - describe 'without a description' do - it 'is invalid' do + describe "without a description" do + it "is invalid" do subject = EntryValidator.new({}) assert_raises(TermMissingDescriptionError) { subject.validate(invalid_term_no_desc) } end end - describe 'with extra keys' do - it 'is invalid' do + describe "with extra keys" do + it "is invalid" do subject = EntryValidator.new({}) assert_raises(BadSchemaError) { subject.validate(invalid_term_extra_keys) } end end - describe 'without cross-references' do - it 'is valid' do + describe "without cross-references" do + it "is valid" do subject = EntryValidator.new({}) assert_equal true, subject.validate(valid_term_no_crossref) end end - describe 'with cross-references' do - describe 'that all match' do - it 'is valid' do + describe "with cross-references" do + describe "that all match" do + it "is valid" do subject = EntryValidator.new(context_matching_crossrefs) assert_equal true, subject.validate(valid_term_matching_crossrefs) end end describe "that don't match" do - it 'is invalid' do + it "is invalid" do subject = EntryValidator.new(context_matching_crossrefs) assert_raises(TermNotFoundError) { subject.validate(invalid_term_mismatched_crossrefs) } end end - describe 'to a valid acronym' do - it 'is invalid' do + describe "to a valid acronym" do + it "is invalid" do subject = EntryValidator.new(context_term_cross_references_acronym) assert_raises(CrossreferencesAcronymError) { subject.validate(invalid_term_crossrefs_acronym) } end end end - describe 'with an explicitly null description' do - it 'is valid' do + describe "with an explicitly null description" do + it "is valid" do subject = EntryValidator.new({}) assert_equal true, subject.validate(valid_term_null_desc) end end end - describe 'acronym' do - describe 'without a type' do - it 'is invalid' do + describe "acronym" do + describe "without a type" do + it "is invalid" do subject = EntryValidator.new({}) assert_raises(EntryTypeError) { subject.validate(invalid_acronym_no_type) } end end - describe 'without a term' do - it 'is invalid' do + describe "without a term" do + it "is invalid" do subject = EntryValidator.new({}) assert_raises(MissingTermError) { subject.validate(invalid_acronym_no_term) } end end - describe 'with an explicitly null term' do - it 'is invalid' do + describe "with an explicitly null term" do + it "is invalid" do subject = EntryValidator.new({}) assert_raises(MissingTermError) { subject.validate(invalid_acronym_null_term) } end end - describe 'with any other keys' do - it 'is invalid' do + describe "with any other keys" do + it "is invalid" do subject = EntryValidator.new(valid_term) assert_raises(BadSchemaError) { subject.validate(invalid_acronym_extra_keys) } end end - describe 'valid' do - describe 'referring to one term' do - describe 'matching a valid term' do - it 'is valid' do + describe "valid" do + describe "referring to one term" do + describe "matching a valid term" do + it "is valid" do subject = EntryValidator.new(context_for_valid_term) assert_equal true, subject.validate(valid_acronym) end end - describe 'matching an invalid term' do - it 'is valid' do + describe "matching an invalid term" do + it "is valid" do subject = EntryValidator.new(context_for_invalid_term) assert_equal true, subject.validate(valid_acronym) end end - describe 'that does not match' do - it 'is invalid' do + describe "that does not match" do + it "is invalid" do subject = EntryValidator.new({}) assert_raises(TermNotFoundError) { subject.validate(valid_acronym) } end @@ -132,22 +133,22 @@ end end - describe 'referring to another acronym' do - it 'is invalid' do + describe "referring to another acronym" do + it "is invalid" do subject = EntryValidator.new(context_for_invalid_acronym_refers_to_acronym) assert_raises(AcronymReferenceError) { subject.validate(invalid_acronym_refers_to_acronym) } end end - describe 'referring to multiple terms' do - describe 'which all match' do - it 'is valid' do + describe "referring to multiple terms" do + describe "which all match" do + it "is valid" do subject = EntryValidator.new(context_for_valid_term_multi) assert_equal true, subject.validate(valid_acronym_multi) end end describe "one of which doesn't match a term" do - it 'is invalid' do + it "is invalid" do subject = EntryValidator.new(valid_term_pop1) assert_raises(TermNotFoundError) { subject.validate(valid_acronym_multi) } end