From fb922422cf2826bb1c39c185a55d570445a7707d Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Wed, 2 Dec 2026 13:30:10 -0600 Subject: [PATCH] Enable RSpec/ContextWording --- .rubocop_todo.yml | 6 ---- spec/controllers/catalog_controller_spec.rb | 2 +- spec/features/autocomplete_spec.rb | 2 +- spec/features/collection_page_spec.rb | 6 ++-- spec/features/component_page_spec.rb | 6 ++-- spec/features/google_form_request_spec.rb | 8 +++--- spec/features/online_content_spec.rb | 4 +-- spec/features/search_breadcrumb_spec.rb | 2 +- spec/features/search_query_spec.rb | 14 +++++----- spec/features/search_results_spec.rb | 2 +- spec/features/traject/ead2_indexing_spec.rb | 2 +- spec/helpers/arclight_helper_spec.rb | 4 +-- spec/lib/arclight/normalized_date_spec.rb | 18 ++++++------ spec/lib/arclight/normalized_title_spec.rb | 28 +++++++++---------- spec/routing/arclight/repositories_spec.rb | 2 +- .../views/repositories/index.html.erb_spec.rb | 6 ++-- spec/views/repositories/show.html.erb_spec.rb | 2 +- 17 files changed, 54 insertions(+), 60 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 811ca19e6..ecbd486f3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -34,12 +34,6 @@ Metrics/MethodLength: Metrics/PerceivedComplexity: Max: 9 -# Offense count: 60 -# Configuration parameters: Prefixes, AllowedPatterns. -# Prefixes: when, with, without -RSpec/ContextWording: - Enabled: false - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SkipBlocks, EnforcedStyle. diff --git a/spec/controllers/catalog_controller_spec.rb b/spec/controllers/catalog_controller_spec.rb index 728440c3f..050878d7d 100644 --- a/spec/controllers/catalog_controller_spec.rb +++ b/spec/controllers/catalog_controller_spec.rb @@ -4,7 +4,7 @@ RSpec.describe CatalogController do describe 'index action customizations' do - context 'any other view' do + context 'with any other view' do it 'starts a search_session' do allow(controller).to receive(:search_results) session[:history] = [] diff --git a/spec/features/autocomplete_spec.rb b/spec/features/autocomplete_spec.rb index 102de9f68..b0ee268dd 100644 --- a/spec/features/autocomplete_spec.rb +++ b/spec/features/autocomplete_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Autocomplete', :js do - context 'site-wide search form' do + describe 'site-wide search form' do it 'is configured properly to allow non-prefix autocomplete' do visit '/catalog' find_by_id('q').send_keys 'by-laws' diff --git a/spec/features/collection_page_spec.rb b/spec/features/collection_page_spec.rb index 4bec99f96..a35c41db5 100644 --- a/spec/features/collection_page_spec.rb +++ b/spec/features/collection_page_spec.rb @@ -164,7 +164,7 @@ end end - context 'sections that do not have metadata' do + context 'with sections that do not have metadata' do let(:doc_id) { 'm0198-xml' } it 'are not displayed' do @@ -183,7 +183,7 @@ end end - context 'for sections that do not have metadata' do + context 'with sections that do not have metadata' do let(:doc_id) { 'm0198-xml' } it 'does not include links to those sections' do @@ -264,7 +264,7 @@ end end - context 'content with file downloads', :js do + context 'with content that has file downloads', :js do let(:doc_id) { 'a0011-xml_aspace_ref6_lx4' } it 'renders links to the files for download' do diff --git a/spec/features/component_page_spec.rb b/spec/features/component_page_spec.rb index 713edc695..26047d812 100644 --- a/spec/features/component_page_spec.rb +++ b/spec/features/component_page_spec.rb @@ -159,7 +159,7 @@ def wait_for_hierarchy_to_load end end - context 'siblings and highlighted self' do + describe 'siblings and highlighted self' do it 'has all siblings' do within '#collection-context' do expect(page).to have_css( @@ -199,7 +199,7 @@ def wait_for_hierarchy_to_load end end - context 'duplicate titles' do + context 'with duplicate titles' do let(:doc_id) { 'lc0100_aspace_c5ef89d4ae68bb77e7c641f3edb3f1c8' } it 'does not highlight duplicate titles' do @@ -317,7 +317,7 @@ def wait_for_hierarchy_to_load end end - context 'content with file downloads', :js do + context 'with content that has file downloads', :js do let(:doc_id) { 'a0011-xml_aspace_ref6_lx4' } it 'renders links to the files for download' do diff --git a/spec/features/google_form_request_spec.rb b/spec/features/google_form_request_spec.rb index a377ec24a..1d0b30d00 100644 --- a/spec/features/google_form_request_spec.rb +++ b/spec/features/google_form_request_spec.rb @@ -4,7 +4,7 @@ xdescribe 'Google Form Request', :js do context 'when container is present' do - context 'repository is requestable' do + context 'when the repository is requestable' do it 'form is present with filled out values' do visit solr_document_path 'aoa271_aspace_843e8f9f22bac69872d0802d6fffbb04' @@ -23,7 +23,7 @@ end end - context 'repository is not requestable' do + context 'when the repository is not requestable' do it 'form is absent' do visit solr_document_path 'm0198-xml_aspace_ref14_di4' expect(page).to have_css 'h1' @@ -41,14 +41,14 @@ end end - context 'in search results' do + context 'when in search results' do it 'shows up when item is requestable' do visit search_catalog_path q: 'alpha', search_field: 'all_fields' expect(page).to have_css 'form[action*="https://docs.google.com"]', count: 4 end end - context 'in collection hierarchy' do + context 'when in the collection hierarchy' do it 'shows up in hierarchy' do visit solr_document_path 'aoa271' click_on 'Contents' diff --git a/spec/features/online_content_spec.rb b/spec/features/online_content_spec.rb index 3ca821eff..2540e8227 100644 --- a/spec/features/online_content_spec.rb +++ b/spec/features/online_content_spec.rb @@ -8,7 +8,7 @@ before { visit solr_document_path(id: doc_id) } describe 'Viewer' do - context 'embedded content' do + context 'with embedded content' do let(:doc_id) { 'a0011-xml_aspace_ref6_lx4' } it 'renders digital object viewer initialization markup', :js do @@ -19,7 +19,7 @@ end end - context 'non-embeddable content' do + context 'with non-embeddable content' do let(:doc_id) { 'aoa271_aspace_843e8f9f22bac69872d0802d6fffbb04' } it 'renders a list of links', :js do diff --git a/spec/features/search_breadcrumb_spec.rb b/spec/features/search_breadcrumb_spec.rb index 94bf839c7..d2eb58948 100644 --- a/spec/features/search_breadcrumb_spec.rb +++ b/spec/features/search_breadcrumb_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Search Breadcrumb' do - context 'on regular search results' do + context 'when on regular search results' do it do visit search_catalog_path q: 'a brief', search_field: 'all_fields' within '.al-search-breadcrumb' do diff --git a/spec/features/search_query_spec.rb b/spec/features/search_query_spec.rb index a6266ba3e..586999d6c 100644 --- a/spec/features/search_query_spec.rb +++ b/spec/features/search_query_spec.rb @@ -27,49 +27,49 @@ end describe 'default all fields search for' do - context 'EAD ID' do + context 'with an EAD ID' do it 'returns a collection with a matching EAD ID' do visit search_catalog_path q: 'umich-bhl-851981', search_field: 'all_fields' expect(page).to have_css '.index_title', text: /Interlochen Center for The Arts records/ end end - context 'component ref ID' do + context 'with a component ref ID' do it 'returns a component with a matching ref' do visit search_catalog_path q: 'aspace_563a320bb37d24a9e1e6f7bf95b52671', search_field: 'all_fields' expect(page).to have_css '.index_title', text: /Series I: Administrative Records/ end end - context 'component full ID (with eadid & ref)' do + context 'with a component full ID (with eadid & ref)' do it 'returns a component with a matching full ID' do visit search_catalog_path q: 'aoa271_aspace_2d7e583e94eb2b46d5dd1a0ec4cdca1f', search_field: 'all_fields' expect(page).to have_css '.index_title', text: /Dr. Root and L. Raymond Higgins/ end end - context 'container' do + context 'with a container' do it 'returns a component with a matching container' do visit search_catalog_path q: '"box 92"', search_field: 'all_fields' expect(page).to have_css '.index_title', text: /Card index/ end end - context 'language' do + context 'with a language' do it 'returns a component with a matching language' do visit search_catalog_path q: 'english', search_field: 'all_fields' expect(page).to have_css '.index_title', text: /Stanford University student life photograph album/ end end - context 'terms appearing in different ancestor component titles' do + context 'when terms appear in different ancestor component titles' do it 'returns a component where one term hit is only in its parent title' do visit search_catalog_path q: 'administrative hippocrates', search_field: 'all_fields' expect(page).to have_css '.index_title', text: /The constitution of the Alpha Omega/ end end - context 'search containing stand-alone punctuation' do + context 'when the search contains stand-alone punctuation' do it 'returns results' do visit search_catalog_path q: 'constitution amendments - drafts', search_field: 'all_fields' expect(page).to have_css '.index_title', text: /Constitution amendments - drafts/ diff --git a/spec/features/search_results_spec.rb b/spec/features/search_results_spec.rb index 049d673b7..1cea9fe16 100644 --- a/spec/features/search_results_spec.rb +++ b/spec/features/search_results_spec.rb @@ -180,7 +180,7 @@ end end - context 'by relevance without a query' do + context 'when sorting by relevance without a query' do let(:collection) { 'Alpha Omega Alpha Archives, 1894-1992' } it 'lists a collection and its components in the order they appear in the finding aid' do diff --git a/spec/features/traject/ead2_indexing_spec.rb b/spec/features/traject/ead2_indexing_spec.rb index e07dd1939..554c931c4 100644 --- a/spec/features/traject/ead2_indexing_spec.rb +++ b/spec/features/traject/ead2_indexing_spec.rb @@ -363,7 +363,7 @@ def components(result) expect(all_components.length).to eq 38 end - context 'nested component' do + context 'with a nested component' do describe 'accessrestrict' do context 'with its own accessrestrct' do let(:component_with_own_accessrestrict) do diff --git a/spec/helpers/arclight_helper_spec.rb b/spec/helpers/arclight_helper_spec.rb index 97618ccbb..0467b8efc 100644 --- a/spec/helpers/arclight_helper_spec.rb +++ b/spec/helpers/arclight_helper_spec.rb @@ -132,7 +132,7 @@ it { is_expected.to eq 'Collections' } end - context 'all other non-special search behavior' do + context 'with any other search behavior' do it { is_expected.to eq 'Search' } end end @@ -144,7 +144,7 @@ expect(helper.document_level_icon(document)).to eq 'collection' end - context 'there is no level_ssm' do + context 'when there is no level_ssm' do let(:document) { SolrDocument.new } it 'gives the default icon' do diff --git a/spec/lib/arclight/normalized_date_spec.rb b/spec/lib/arclight/normalized_date_spec.rb index 6f0eee863..b5f2ad5d4 100644 --- a/spec/lib/arclight/normalized_date_spec.rb +++ b/spec/lib/arclight/normalized_date_spec.rb @@ -9,12 +9,12 @@ let(:date_bulk) { '1999-2005' } let(:date_other) { 'Undated' } - context 'under normal conditions' do + context 'with inclusive, bulk, and other dates' do it 'joins dates' do expect(normalized_date).to eq '1990-2000, Undated, bulk 1999-2005' end - context 'multiple normalized dates' do + context 'with multiple normalized dates' do let(:date_inclusive) { %w[1990 1992] } it 'are joined w/ a comma' do @@ -26,7 +26,7 @@ context 'with special case dates' do # NOTE: This test is the only place where the code that exercises this is routable # This has to be a multidimensional array, and the resulting XML nodes sent in are always flat - context 'multiples' do + context 'with multiple date ranges' do let(:date_inclusive) { [%w[1990-2000 2001-2002 2004]] } let(:date_bulk) { '1990-2004' } @@ -35,7 +35,7 @@ end end - context 'undated' do + context 'with an undated bulk date' do let(:date_bulk) { 'n.d.' } it 'do not normalized term "undated"' do @@ -43,7 +43,7 @@ end end - context 'circa' do + context 'with a circa bulk date' do let(:date_bulk) { 'c.1995' } it 'do not normalized term "circa"' do @@ -51,7 +51,7 @@ end end - context 'no bulk' do + context 'without bulk or other dates' do let(:date_bulk) { nil } let(:date_other) { nil } @@ -60,7 +60,7 @@ end end - context 'no inclusive or bulk but other' do + context 'with only an other date' do let(:date_inclusive) { nil } let(:date_bulk) { nil } let(:date_other) { 'n.d.' } @@ -70,7 +70,7 @@ end end - context 'no inclusive but bulk' do + context 'without an inclusive date' do let(:date_inclusive) { nil } it 'uses other and bulk' do @@ -78,7 +78,7 @@ end end - context 'no information' do + context 'without any dates' do let(:date_inclusive) { nil } let(:date_bulk) { nil } let(:date_other) { nil } diff --git a/spec/lib/arclight/normalized_title_spec.rb b/spec/lib/arclight/normalized_title_spec.rb index cf3873b21..1850bc5dd 100644 --- a/spec/lib/arclight/normalized_title_spec.rb +++ b/spec/lib/arclight/normalized_title_spec.rb @@ -9,14 +9,14 @@ let(:date) { '1990-2000' } let(:id) { '1234' } - context 'under normal conditions' do + context 'with a title and date' do it 'joins the title and date' do expect(normalized_title).to eq 'My Title, 1990-2000' end end context 'with special case titles' do - context 'punctuated titles' do + context 'with a punctuated title' do let(:title) { 'My, Title' } it 'joins the title as-is and date' do @@ -24,7 +24,7 @@ end end - context 'buggy title (comma at end)' do + context 'with a trailing comma' do let(:title) { 'My Title,' } it 'cleans up the title and joins with the date' do @@ -32,7 +32,7 @@ end end - context 'buggy title (quoted comma at end)' do + context 'with a trailing comma inside quotes' do let(:title) { '"My Title,"' } it 'is buggy but we allow it' do @@ -40,7 +40,7 @@ end end - context 'spacey title' do + context 'with surrounding whitespace' do let(:title) { ' My Title ' } it 'cleans up the title and joins with the date' do @@ -48,7 +48,7 @@ end end - context 'blank title' do + context 'with a blank title' do let(:title) { ' ' } it 'uses only the date' do @@ -56,7 +56,7 @@ end end - context 'missing title' do + context 'without a title' do let(:title) { nil } it 'uses only the date' do @@ -66,7 +66,7 @@ end context 'with special case dates' do - context 'spacey date' do + context 'with surrounding whitespace' do let(:date) { ' 1990-2000 ' } it 'joins the title and date' do @@ -74,7 +74,7 @@ end end - context 'just n.d.' do + context 'with just n.d.' do let(:date) { 'n.d.' } it 'joins the title and date as-is' do @@ -82,7 +82,7 @@ end end - context 'extra n.d.' do + context 'with an extra n.d.' do let(:date) { '1990-2000, bulk n.d.' } it 'joins the title and date as-is' do @@ -90,7 +90,7 @@ end end - context 'extra year/range' do + context 'with an extra year/range' do let(:date) { '1956-1994, bulk 1968-1993' } it 'joins the title and date as-is' do @@ -98,7 +98,7 @@ end end - context 'blank date' do + context 'with a blank date' do let(:date) { ' ' } it 'uses only the title' do @@ -106,7 +106,7 @@ end end - context 'missing date' do + context 'without a date' do let(:date) { nil } it 'uses only the title' do @@ -115,7 +115,7 @@ end end - context 'no title or date' do + context 'without a title or date' do let(:title) { nil } let(:date) { nil } diff --git a/spec/routing/arclight/repositories_spec.rb b/spec/routing/arclight/repositories_spec.rb index 2ebde73cb..a8d519a1f 100644 --- a/spec/routing/arclight/repositories_spec.rb +++ b/spec/routing/arclight/repositories_spec.rb @@ -4,7 +4,7 @@ RSpec.describe 'Vanity repositories routes' do routes { Arclight::Engine.routes } - context 'repositories' do + describe 'repositories' do it '#index' do expect(get: '/repositories').to route_to( controller: 'arclight/repositories', diff --git a/spec/views/repositories/index.html.erb_spec.rb b/spec/views/repositories/index.html.erb_spec.rb index 7d046b91f..c2ad87ca3 100644 --- a/spec/views/repositories/index.html.erb_spec.rb +++ b/spec/views/repositories/index.html.erb_spec.rb @@ -11,7 +11,7 @@ allow(view).to receive_messages(search_action_path: '/', on_repositories_index?: true) end - context 'renders the three repository examples' do + describe 'the three repository examples' do before { render } it 'has the header class' do @@ -54,7 +54,7 @@ expect(rendered).to have_css('.al-repository-contact-phone', count: 2) end - context 'collection counts' do + describe 'collection counts' do it '0 collections' do within('.al-repository-extra-collection-count') do expect(rendered).to have_css('.al-repository-collection-count', text: 'No collections') @@ -75,7 +75,7 @@ end end - context 'switched extra content' do + describe 'extra content' do it 'shows on repositories page' do render expect(rendered).to have_css('.al-repository-extra', count: 5) diff --git a/spec/views/repositories/show.html.erb_spec.rb b/spec/views/repositories/show.html.erb_spec.rb index cdbbcb117..002a70fe9 100644 --- a/spec/views/repositories/show.html.erb_spec.rb +++ b/spec/views/repositories/show.html.erb_spec.rb @@ -12,7 +12,7 @@ allow(view).to receive(:search_action_url).and_return('/') end - context 'renders a repository detail page' do + describe 'the repository detail page' do before { render } it 'has the repository card' do