diff --git a/marc_to_solr/lib/genre.rb b/marc_to_solr/lib/genre.rb index b367f14d..38034e48 100644 --- a/marc_to_solr/lib/genre.rb +++ b/marc_to_solr/lib/genre.rb @@ -81,7 +81,7 @@ def genres_from_autobiography def genre_term_indicates_primary_source?(genre) normalized_genre = genre.downcase.strip.delete_suffix('.') - primary_source_genres.any? { |primary_source_genre| normalized_genre.include? primary_source_genre } + primary_source_genres.any? { |primary_source_genre| normalized_genre.match?(/(^|\W)#{primary_source_genre}($|\W)/) } end def biography? diff --git a/spec/marc_to_solr/lib/genre_spec.rb b/spec/marc_to_solr/lib/genre_spec.rb index 11f7377d..4fe904fc 100644 --- a/spec/marc_to_solr/lib/genre_spec.rb +++ b/spec/marc_to_solr/lib/genre_spec.rb @@ -120,6 +120,16 @@ expect(genres).to include('Primary source') end end + context 'when the 650 subfield x has Computer network resources' do + let(:genres) do + g650 = { "650" => { "ind1" => " ", "ind2" => "0", "subfields" => [{ "a" => "Dating (Social customs)" }, { "x" => "Computer network resources." }] } } + sample_marc = MARC::Record.new_from_hash('fields' => [g650]) + described_class.new(sample_marc).to_a + end + it 'does not include Primary Source in the list of genres' do + expect(genres).not_to include('Primary source') + end + end context 'when the 650 subfield a is Biography' do let(:genres) do g650 = { "650" => { "ind1" => " ", "ind2" => "0", "subfields" => [{ "a" => "Biography" }] } }