From f42872947fac5fd87575f9e55069e50bd4d45ef8 Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Wed, 4 Dec 2024 15:21:21 -0600 Subject: [PATCH] Add new Rubocops and correct them --- .rubocop.yml | 154 ++++++++++++++++++ app/models/arclight/document_downloads.rb | 2 +- lib/arclight/repository.rb | 2 +- lib/arclight/traject/ead2_component_config.rb | 2 +- .../arclight/breadcrumb_component_spec.rb | 4 +- .../repository_location_component_spec.rb | 2 +- spec/features/aeon_web_ead_request_spec.rb | 4 +- spec/features/autocomplete_spec.rb | 2 +- spec/features/bookmarks_spec.rb | 4 +- spec/features/collection_context_spec.rb | 2 +- spec/features/collection_filtering_spec.rb | 6 +- spec/features/collection_page_spec.rb | 18 +- spec/features/compact_search_results_spec.rb | 6 +- spec/features/component_page_spec.rb | 10 +- spec/features/google_form_request_spec.rb | 4 +- spec/features/item_breadcrumbs_spec.rb | 2 +- spec/features/many_component_ead_spec.rb | 6 +- spec/features/online_content_spec.rb | 4 +- spec/features/repositories_page_spec.rb | 10 +- spec/features/search_results_spec.rb | 2 +- spec/lib/arclight/repository_spec.rb | 2 +- spec/views/_requests.html.erb_spec.rb | 16 +- .../views/repositories/index.html.erb_spec.rb | 3 +- 23 files changed, 208 insertions(+), 59 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0967490b6..221198927 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -362,3 +362,157 @@ RSpecRails/MinitestAssertions: # new in 2.17 Enabled: true Rails/ResponseParsedBody: # new in 2.18 Enabled: true +Gemspec/AddRuntimeDependency: # new in 1.65 + Enabled: true +Lint/DuplicateMatchPattern: # new in 1.50 + Enabled: true +Lint/DuplicateSetElement: # new in 1.67 + Enabled: true +Lint/HashNewWithKeywordArgumentsAsDefault: # new in 1.69 + Enabled: true +Lint/ItWithoutArgumentsInBlock: # new in 1.59 + Enabled: true +Lint/LiteralAssignmentInCondition: # new in 1.58 + Enabled: true +Lint/MixedCaseRange: # new in 1.53 + Enabled: true +Lint/NumericOperationWithConstantResult: # new in 1.69 + Enabled: true +Lint/RedundantRegexpQuantifiers: # new in 1.53 + Enabled: true +Lint/UnescapedBracketInRegexp: # new in 1.68 + Enabled: true +Lint/UselessDefined: # new in 1.69 + Enabled: true +Lint/UselessNumericOperation: # new in 1.66 + Enabled: true +Metrics/CollectionLiteralLength: # new in 1.47 + Enabled: true +Style/AmbiguousEndlessMethodDefinition: # new in 1.68 + Enabled: true +Style/BitwisePredicate: # new in 1.68 + Enabled: true +Style/CombinableDefined: # new in 1.68 + Enabled: true +Style/DataInheritance: # new in 1.49 + Enabled: true +Style/DigChain: # new in 1.69 + Enabled: true +Style/DirEmpty: # new in 1.48 + Enabled: true +Style/ExactRegexpMatch: # new in 1.51 + Enabled: true +Style/FileEmpty: # new in 1.48 + Enabled: true +Style/FileNull: # new in 1.69 + Enabled: true +Style/FileTouch: # new in 1.69 + Enabled: true +Style/KeywordArgumentsMerging: # new in 1.68 + Enabled: true +Style/MapIntoArray: # new in 1.63 + Enabled: true +Style/RedundantArrayConstructor: # new in 1.52 + Enabled: true +Style/RedundantCurrentDirectoryInPath: # new in 1.53 + Enabled: true +Style/RedundantFilterChain: # new in 1.52 + Enabled: true +Style/RedundantInterpolationUnfreeze: # new in 1.66 + Enabled: true +Style/RedundantLineContinuation: # new in 1.49 + Enabled: true +Style/RedundantRegexpArgument: # new in 1.53 + Enabled: true +Style/RedundantRegexpConstructor: # new in 1.52 + Enabled: true +Style/ReturnNilInPredicateMethodDefinition: # new in 1.53 + Enabled: true +Style/SafeNavigationChainLength: # new in 1.68 + Enabled: true +Style/SendWithLiteralMethodName: # new in 1.64 + Enabled: true +Style/SingleLineDoEndBlock: # new in 1.57 + Enabled: true +Style/SuperArguments: # new in 1.64 + Enabled: true +Style/SuperWithArgsParentheses: # new in 1.58 + Enabled: true +Style/YAMLFileRead: # new in 1.53 + Enabled: true +Capybara/ClickLinkOrButtonStyle: # new in 2.19 + Enabled: true +Capybara/RedundantWithinFind: # new in 2.20 + Enabled: true +Capybara/RSpec/HaveSelector: # new in 2.19 + Enabled: true +Capybara/RSpec/PredicateMatcher: # new in 2.19 + Enabled: true +FactoryBot/AssociationStyle: # new in 2.23 + Enabled: true +FactoryBot/ExcessiveCreateList: # new in 2.25 + Enabled: true +FactoryBot/FactoryAssociationWithStrategy: # new in 2.23 + Enabled: true +FactoryBot/IdSequence: # new in 2.24 + Enabled: true +FactoryBot/RedundantFactoryOption: # new in 2.23 + Enabled: true +RSpecRails/NegationBeValid: # new in 2.23 + Enabled: true +RSpecRails/TravelAround: # new in 2.19 + Enabled: true +RSpec/BeEmpty: # new in 2.20 + Enabled: true +RSpec/ContainExactly: # new in 2.19 + Enabled: true +RSpec/EmptyMetadata: # new in 2.24 + Enabled: true +RSpec/EmptyOutput: # new in 2.29 + Enabled: true +RSpec/Eq: # new in 2.24 + Enabled: true +RSpec/ExpectInLet: # new in 2.30 + Enabled: true +RSpec/IndexedLet: # new in 2.20 + Enabled: true +RSpec/IsExpectedSpecify: # new in 2.27 + Enabled: true +RSpec/MatchArray: # new in 2.19 + Enabled: true +RSpec/MetadataStyle: # new in 2.24 + Enabled: true +RSpec/ReceiveMessages: # new in 2.23 + Enabled: true +RSpec/RedundantAround: # new in 2.19 + Enabled: true +RSpec/RedundantPredicateMatcher: # new in 2.26 + Enabled: true +RSpec/RemoveConst: # new in 2.26 + Enabled: true +RSpec/RepeatedSubjectCall: # new in 2.27 + Enabled: true +RSpec/SkipBlockInsideExample: # new in 2.19 + Enabled: true +RSpec/SpecFilePathFormat: # new in 2.24 + Enabled: true +RSpec/SpecFilePathSuffix: # new in 2.24 + Enabled: true +RSpec/UndescriptiveLiteralsDescription: # new in 2.29 + Enabled: true +Rails/DangerousColumnNames: # new in 2.21 + Enabled: true +Rails/EnumSyntax: # new in 2.26 + Enabled: true +Rails/EnvLocal: # new in 2.22 + Enabled: true +Rails/RedundantActiveRecordAllMethod: # new in 2.21 + Enabled: true +Rails/SelectMap: # new in 2.21 + Enabled: true +Rails/ThreeStateBooleanColumn: # new in 2.19 + Enabled: true +Rails/UnusedRenderContent: # new in 2.21 + Enabled: true +Rails/WhereRange: # new in 2.25 + Enabled: true diff --git a/app/models/arclight/document_downloads.rb b/app/models/arclight/document_downloads.rb index 5095ff4b1..8a47c0af3 100644 --- a/app/models/arclight/document_downloads.rb +++ b/app/models/arclight/document_downloads.rb @@ -33,7 +33,7 @@ def files class << self def config @config ||= begin - YAML.safe_load(::File.read(config_filename)) + YAML.safe_load_file(config_filename) rescue Errno::ENOENT {} end diff --git a/lib/arclight/repository.rb b/lib/arclight/repository.rb index 535379a82..76a14fac7 100644 --- a/lib/arclight/repository.rb +++ b/lib/arclight/repository.rb @@ -72,7 +72,7 @@ def available_request_types # @return [Hash] def self.from_yaml(file) repos = {} - data = YAML.safe_load(File.read(file)) + data = YAML.safe_load_file(file) data.each_key do |slug| repos[slug] = new(data[slug].merge(slug: slug)) end diff --git a/lib/arclight/traject/ead2_component_config.rb b/lib/arclight/traject/ead2_component_config.rb index 7ce452727..64c17d0d3 100644 --- a/lib/arclight/traject/ead2_component_config.rb +++ b/lib/arclight/traject/ead2_component_config.rb @@ -86,7 +86,7 @@ record['id'] = hexdigest hexdigest else - record.attribute('id')&.value&.strip&.gsub('.', '-') + record.attribute('id')&.value&.strip&.gsub('.', '-') # rubocop:disable Style/SafeNavigationChainLength end end to_field 'ref_ssm' do |_record, accumulator, context| diff --git a/spec/components/arclight/breadcrumb_component_spec.rb b/spec/components/arclight/breadcrumb_component_spec.rb index ffae3666c..e0dc040a2 100644 --- a/spec/components/arclight/breadcrumb_component_spec.rb +++ b/spec/components/arclight/breadcrumb_component_spec.rb @@ -29,7 +29,7 @@ let(:attr) { { count: 2 } } it 'renders only that many breadcrumb links' do - expect(rendered).to have_selector 'li', text: 'my repository' + expect(rendered).to have_css 'li', text: 'my repository' expect(rendered).to have_link 'ABC123', href: '/catalog/abc123' expect(rendered).to have_no_link 'DEF', href: '/catalog/abc123_def' expect(rendered).to have_no_link 'GHI', href: '/catalog/abc123_ghi' @@ -52,7 +52,7 @@ end it 'renders breadcrumb links' do - expect(rendered).to have_selector 'li', text: 'my repository' + expect(rendered).to have_css 'li', text: 'my repository' expect(rendered).to have_link 'DEF', href: '/catalog/abc123_def' expect(rendered).to have_link 'GHI', href: '/catalog/abc123_ghi' end diff --git a/spec/components/arclight/repository_location_component_spec.rb b/spec/components/arclight/repository_location_component_spec.rb index 6ac838495..7df043487 100644 --- a/spec/components/arclight/repository_location_component_spec.rb +++ b/spec/components/arclight/repository_location_component_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Arclight::RepositoryLocationComponent, type: :component do let(:field) do - instance_double(Blacklight::FieldPresenter, key: 'blah', document: nil, label: 'blah', values: [Arclight::Repository.all.first], render_field?: true) + instance_double(Blacklight::FieldPresenter, key: 'blah', document: nil, label: 'blah', values: [Arclight::Repository.first], render_field?: true) end let(:render) do component.render_in(vc_test_controller.view_context) diff --git a/spec/features/aeon_web_ead_request_spec.rb b/spec/features/aeon_web_ead_request_spec.rb index 92310d34d..84a97a2d6 100644 --- a/spec/features/aeon_web_ead_request_spec.rb +++ b/spec/features/aeon_web_ead_request_spec.rb @@ -2,13 +2,13 @@ require 'spec_helper' -describe 'Aeon Web EAD Request', js: true do +describe 'Aeon Web EAD Request', :js do context 'when EAD URL template is provided' do it 'creates a request link' do visit solr_document_path 'm0198-xml' within '#m0198-xml_aspace_ref11_d0s-hierarchy-item' do - click_link 'Pages 1-78' + click_on 'Pages 1-78' end expect(page).to have_css( 'a[href*="https://sample.request.com?Action=10&Form=31&Value=http%3A%2F%2Fexample.com%2FM0198.xml', diff --git a/spec/features/autocomplete_spec.rb b/spec/features/autocomplete_spec.rb index 35f962c50..23eb9f869 100644 --- a/spec/features/autocomplete_spec.rb +++ b/spec/features/autocomplete_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Autocomplete', js: true do +RSpec.describe 'Autocomplete', :js do context 'site-wide search form' do it 'is configured properly to allow non-prefix autocomplete' do visit '/catalog' diff --git a/spec/features/bookmarks_spec.rb b/spec/features/bookmarks_spec.rb index ea0e207a2..c55ead36f 100644 --- a/spec/features/bookmarks_spec.rb +++ b/spec/features/bookmarks_spec.rb @@ -3,10 +3,10 @@ require 'spec_helper' RSpec.describe 'Bookmarks' do - it 'shows bookmarks as checkboxes', js: true do + it 'shows bookmarks as checkboxes', :js do visit solr_document_path('aoa271_aspace_a951375d104030369a993ff943f61a77') check 'Bookmark' - click_link 'Bookmarks' + click_on 'Bookmarks' visit solr_document_path('aoa271_aspace_a951375d104030369a993ff943f61a77') expect(page).to have_css('input[type="checkbox"][checked]') diff --git a/spec/features/collection_context_spec.rb b/spec/features/collection_context_spec.rb index 3e243706e..565d3b73f 100644 --- a/spec/features/collection_context_spec.rb +++ b/spec/features/collection_context_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Collection context', js: true do +RSpec.describe 'Collection context', :js do let(:doc_id) { 'aoa271_aspace_6ea193f778e553ca9ea0d00a3e5a1891' } before do diff --git a/spec/features/collection_filtering_spec.rb b/spec/features/collection_filtering_spec.rb index 1a5af3c6b..3eaefee0d 100644 --- a/spec/features/collection_filtering_spec.rb +++ b/spec/features/collection_filtering_spec.rb @@ -19,7 +19,7 @@ select 'all collections', from: 'Search within' - click_button 'Search' + click_on 'Search' expect(page).to have_css('.al-document-listings .document', count: 10) # has results expect(page).to have_no_css('.constraint-value .filter-value', text: 'Alpha Omega Alpha Archives, 1894-1992') @@ -49,7 +49,7 @@ visit solr_document_path('aoa271_aspace_dba76dab6f750f31aa5fc73e5402e71d') fill_in 'q', with: 'File' - click_button 'Search' + click_on 'Search' expect(page).to have_css('.constraint-value .filter-value', text: 'Alpha Omega Alpha Archives, 1894-1992') expect(page).to have_css('.al-document-listings .document', count: 2) # has results @@ -60,7 +60,7 @@ select 'all collections', from: 'Search within' fill_in 'q', with: 'File' - click_button 'Search' + click_on 'Search' expect(page).to have_no_css('.constraint-value .filter-value', text: 'Alpha Omega Alpha Archives, 1894-1992') expect(page).to have_css('.al-document-listings .document', count: 10) # has results diff --git a/spec/features/collection_page_spec.rb b/spec/features/collection_page_spec.rb index d9898445a..e3e0c7a04 100644 --- a/spec/features/collection_page_spec.rb +++ b/spec/features/collection_page_spec.rb @@ -156,7 +156,7 @@ it 'indexed name terms link to the appropriate name facet' do name = 'Root, William Webster, 1867-1932' within '#indexed-terms' do - click_link name + click_on name end within '.blacklight-names.facet-limit-active' do @@ -195,10 +195,10 @@ end describe 'context and contents' do - describe 'interactions', js: true do + describe 'interactions', :js do it 'contents contain linked level 1 components' do within '#collection-context' do - click_link 'Series I: Administrative Records, 1902-1976' + click_on 'Series I: Administrative Records, 1902-1976' end expect(page).to have_css '.show-document', text: /Series I: Administrative Records/ end @@ -206,20 +206,20 @@ it 'sub components are viewable and expandable' do within '#collection-context' do within '#aoa271_aspace_563a320bb37d24a9e1e6f7bf95b52671-hierarchy-item' do - click_link 'View' + click_on 'View' within '#aoa271_aspace_dc2aaf83625280ae2e193beb3f4aea78-hierarchy-item.al-collection-context' do expect(page).to have_link 'Constitution and by-laws' end - click_link 'Expand' + click_on 'Expand' expect(page).to have_link 'Reports' el = find_by_id('aoa271_aspace_238a0567431f36f49acea49ef576d408-hierarchy-item') evaluate_script "window.scrollTo(0,#{el.rect.y - 100})" sleep 1 within '#aoa271_aspace_238a0567431f36f49acea49ef576d408-hierarchy-item' do - click_link 'View' + click_on 'View' expect(page).to have_link 'Expansion Plan' within '#aoa271_aspace_f934f1add34289f28bd0feb478e68275-hierarchy-item' do - click_link 'View' + click_on 'View' expect(page).to have_link 'Initial Phase' expect(page).to have_link 'Phase II: Expansion' end @@ -256,12 +256,12 @@ end end - context 'content with file downloads', js: true do + context 'content with file downloads', :js do let(:doc_id) { 'a0011-xml_aspace_ref6_lx4' } it 'renders links to the files for download' do within '.al-show-actions-box-downloads-container' do - click_button 'Download' + click_on 'Download' expect(page).to have_link 'Finding aid' expect(page).to have_link 'EAD' end diff --git a/spec/features/compact_search_results_spec.rb b/spec/features/compact_search_results_spec.rb index 29f3dee80..14d43478d 100644 --- a/spec/features/compact_search_results_spec.rb +++ b/spec/features/compact_search_results_spec.rb @@ -5,12 +5,12 @@ RSpec.describe 'Compact Search Results' do it 'As a user I should be able to view results in a compact display' do visit root_path - click_button 'Search' + click_on 'Search' expect(page).to have_css('.documents-list') expect(page).to have_css('h3.index_title', text: 'Alpha Omega Alpha Archives, 1894-1992') - click_link 'Compact' + click_on 'Compact' expect(page).to have_no_css('.documents-list') expect(page).to have_css('.documents-compact') @@ -29,7 +29,7 @@ it 'Shows highlights in compact view' do visit search_catalog_path q: 'william root', search_field: 'name' - click_link 'Compact' + click_on 'Compact' within '.document-position-1' do within '.al-document-highlight' do expect(page).to have_css 'em', text: 'William' diff --git a/spec/features/component_page_spec.rb b/spec/features/component_page_spec.rb index 6e6b02387..1b7896571 100644 --- a/spec/features/component_page_spec.rb +++ b/spec/features/component_page_spec.rb @@ -133,7 +133,7 @@ end end - describe 'collection context', js: true do + describe 'collection context', :js do it 'has ancestor component with badge having children count' do within '#collection-context' do expect(page).to have_css( @@ -161,7 +161,7 @@ it 'supports clicks within collection context' do within '#collection-context' do - click_link('Statements of purpose, c.1902') + click_on('Statements of purpose, c.1902') end expect(page).to have_css 'h1', text: 'Statements of purpose, c.1902' within '#collection-context' do @@ -171,7 +171,7 @@ '.document-title-heading', text: 'Constitution - notes on drafting of constitution, c.1902-1903' ) - click_link 'Constitution - notes on drafting of constitution, c.1902-1903' + click_on 'Constitution - notes on drafting of constitution, c.1902-1903' end expect(page).to have_css 'h1', text: 'Constitution - notes on drafting of constitution, c.1902-1903' within '#collection-context' do @@ -279,12 +279,12 @@ end end - context 'content with file downloads', js: true do + context 'content with file downloads', :js do let(:doc_id) { 'a0011-xml_aspace_ref6_lx4' } it 'renders links to the files for download' do within '.al-show-actions-box-downloads-container' do - click_button 'Download' + click_on 'Download' expect(page).to have_link 'Finding aid' expect(page).to have_link 'EAD' end diff --git a/spec/features/google_form_request_spec.rb b/spec/features/google_form_request_spec.rb index af53a09d3..ea1da9db3 100644 --- a/spec/features/google_form_request_spec.rb +++ b/spec/features/google_form_request_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -xdescribe 'Google Form Request', js: true do +xdescribe 'Google Form Request', :js do context 'when container is present' do context 'repository is requestable' do it 'form is present with filled out values' do @@ -49,7 +49,7 @@ context 'in collection hierarchy' do it 'shows up in hierarchy' do visit solr_document_path 'aoa271' - click_button 'Contents' + click_on 'Contents' first('.al-toggle-view-all').click within '#collection-context' do expect(page).to have_css 'form[action*="https://docs.google.com"]', count: 22 diff --git a/spec/features/item_breadcrumbs_spec.rb b/spec/features/item_breadcrumbs_spec.rb index 16a35d89e..55f2bbc97 100644 --- a/spec/features/item_breadcrumbs_spec.rb +++ b/spec/features/item_breadcrumbs_spec.rb @@ -16,7 +16,7 @@ expect(page).to have_link 'Series I: Administrative Records' expect(page).to have_link 'Reports' expect(page).to have_link 'Expansion Plan' - click_link 'Expansion Plan' + click_on 'Expansion Plan' end end expect(page).to have_css 'h1', text: 'Expansion Plan' diff --git a/spec/features/many_component_ead_spec.rb b/spec/features/many_component_ead_spec.rb index 4df0d1ef5..2c3cdbc80 100644 --- a/spec/features/many_component_ead_spec.rb +++ b/spec/features/many_component_ead_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Many component EAD' do - describe 'hierarchy', js: true do + describe 'hierarchy', :js do before { visit solr_document_path 'lc0100' } it 'includes all components' do @@ -14,8 +14,8 @@ it 'includes all children' do within '#collection-context' do - click_link 'View' - click_link 'Expand' + click_on 'View' + click_on 'Expand' within '#collapsible-hierarchy-lc0100_aspace_327a75c226d44aa1a769edb4d2f13c6e' do expect(page).to have_css 'li.al-collection-context', count: 202 end diff --git a/spec/features/online_content_spec.rb b/spec/features/online_content_spec.rb index 7411913c2..3ca821eff 100644 --- a/spec/features/online_content_spec.rb +++ b/spec/features/online_content_spec.rb @@ -11,7 +11,7 @@ context 'embedded content' do let(:doc_id) { 'a0011-xml_aspace_ref6_lx4' } - it 'renders digital object viewer initialization markup', js: true do + it 'renders digital object viewer initialization markup', :js do expect(page).to have_css( '.al-oembed-viewer[data-arclight-oembed-url-value="http://purl.stanford.edu/kc844kt2526"]', visible: :all @@ -22,7 +22,7 @@ context 'non-embeddable content' do let(:doc_id) { 'aoa271_aspace_843e8f9f22bac69872d0802d6fffbb04' } - it 'renders a list of links', js: true do + it 'renders a list of links', :js do expect(page).to have_link 'Folder of digitized stuff' expect(page).to have_link 'Letter from Christian B. Anfinsen' end diff --git a/spec/features/repositories_page_spec.rb b/spec/features/repositories_page_spec.rb index 10b7e7f00..0af06423d 100644 --- a/spec/features/repositories_page_spec.rb +++ b/spec/features/repositories_page_spec.rb @@ -17,7 +17,7 @@ it 'is navigable form the Repositories page' do visit '/repositories' - click_link 'Stanford University Libraries. Special Collections and University Archives' + click_on 'Stanford University Libraries. Special Collections and University Archives' expect(page).to have_css('h2', text: 'Our Collections') end @@ -25,9 +25,9 @@ it 'links to all the repositories collections' do visit '/repositories' - click_link 'Stanford University Libraries. Special Collections and University Archives' + click_on 'Stanford University Libraries. Special Collections and University Archives' - click_link 'View all of our collections' + click_on 'View all of our collections' expect(page).to have_css('h2', text: 'Search Results') end @@ -35,7 +35,7 @@ it 'does not link the same page in the repository card header' do visit '/repositories' - click_link 'Stanford University Libraries. Special Collections and University Archives' + click_on 'Stanford University Libraries. Special Collections and University Archives' within '.al-repository' do expect(page).to have_no_css( @@ -48,7 +48,7 @@ it 'has a title title starting with the repository name' do visit '/repositories' - click_link 'Stanford University Libraries. Special Collections and University Archives' + click_on 'Stanford University Libraries. Special Collections and University Archives' expect(page.body).to include('Stanford University Libraries. Special Collections and University Archives - Arclight') end diff --git a/spec/features/search_results_spec.rb b/spec/features/search_results_spec.rb index a79634615..fbb254480 100644 --- a/spec/features/search_results_spec.rb +++ b/spec/features/search_results_spec.rb @@ -76,7 +76,7 @@ # Very little metadata exists at the component level to drive any tests it 'renders metadata to meet minumum DACS requirements for a component' - it 'renders facets', js: true do + it 'renders facets', :js do visit search_catalog_path q: '', search_field: 'all_fields' within('#facets') do diff --git a/spec/lib/arclight/repository_spec.rb b/spec/lib/arclight/repository_spec.rb index 697561124..1bde68433 100644 --- a/spec/lib/arclight/repository_spec.rb +++ b/spec/lib/arclight/repository_spec.rb @@ -94,7 +94,7 @@ end it 'has new-style request_type' do - raw_yaml_hash = YAML.safe_load(File.read(repositories_yml_template_file)) + raw_yaml_hash = YAML.safe_load_file(repositories_yml_template_file) nlm = described_class.find_by(slug: 'nlm', yaml_file: repositories_yml_template_file) google_form_url = nlm.request_config_for_type('google_form')['request_url'] expect(google_form_url).to eq raw_yaml_hash['nlm']['request_types']['google_form']['request_url'] diff --git a/spec/views/_requests.html.erb_spec.rb b/spec/views/_requests.html.erb_spec.rb index bc82a2946..5257eedd6 100644 --- a/spec/views/_requests.html.erb_spec.rb +++ b/spec/views/_requests.html.erb_spec.rb @@ -8,11 +8,8 @@ let(:blacklight_config) { Blacklight::Configuration.new } before do - allow(document).to receive(:repository_config).and_return(config) - allow(document).to receive(:requestable?).and_return(true) - allow(view).to receive(:blacklight_config).and_return(blacklight_config) - allow(view).to receive(:action_name).and_return('show') - allow(view).to receive(:document).and_return(document) + allow(document).to receive_messages(repository_config: config, requestable?: true) + allow(view).to receive_messages(blacklight_config: blacklight_config, action_name: 'show', document: document) end context 'with EAD documents which require Aeon requests' do @@ -21,9 +18,9 @@ before do allow(document_downloads).to receive(:href).and_return('https://sample.request.com') allow(document).to receive(:ead_file).and_return(document_downloads) - allow(config).to receive(:available_request_types).and_return([:aeon_web_ead]) - allow(config).to receive(:request_config_for_type).and_return({ 'request_url' => 'https://sample.request.com', - 'request_mappings' => 'Action=10&Form=31&Value=ead_url' }) + allow(config).to receive_messages(available_request_types: [:aeon_web_ead], + request_config_for_type: { 'request_url' => 'https://sample.request.com', + 'request_mappings' => 'Action=10&Form=31&Value=ead_url' }) render end @@ -55,8 +52,7 @@ end before do - allow(config).to receive(:available_request_types).and_return([:aeon_external_request_endpoint]) - allow(config).to receive(:request_config_for_type).and_return(config_hash) + allow(config).to receive_messages(available_request_types: [:aeon_external_request_endpoint], request_config_for_type: config_hash) render end diff --git a/spec/views/repositories/index.html.erb_spec.rb b/spec/views/repositories/index.html.erb_spec.rb index f201695b0..7d046b91f 100644 --- a/spec/views/repositories/index.html.erb_spec.rb +++ b/spec/views/repositories/index.html.erb_spec.rb @@ -8,8 +8,7 @@ before do ENV['REPOSITORY_FILE'] = 'spec/fixtures/config/repositories.yml' assign(:repositories, test_data) - allow(view).to receive(:search_action_path).and_return('/') - allow(view).to receive(:on_repositories_index?).and_return(true) + allow(view).to receive_messages(search_action_path: '/', on_repositories_index?: true) end context 'renders the three repository examples' do