Skip to content

Commit

Permalink
Additional spec tests for fix_008 (#84)
Browse files Browse the repository at this point in the history
* Additional spec tests for fix_008

* added test for fix_book_008

* tests for fix_008 methods for each format

* changes to increase test coverage of code

* added new test to cover specified_008 in fix_008

* added test for bad_008_length? method
  • Loading branch information
Beck-Davis authored Dec 19, 2023
1 parent cc6723b commit 9aea23c
Showing 1 changed file with 177 additions and 65 deletions.
242 changes: 177 additions & 65 deletions spec/fixed_fields/008_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,89 +3,201 @@
require 'byebug'
require 'marc_cleanup'

RSpec.describe 'bad_008?' do
describe 'bad book format 008' do
let(:fields) do
[
{ '008' => '230519s1996 njua u 000 0 eng d' }
]
RSpec.describe 'field 008 methods' do
describe 'bad_008?' do
describe 'bad book format 008' do
let(:fields) do
[
{ '008' => '230519s1996 njuax 000 0 eng d' }
]
end
let(:leader) { '01104naa a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'knows that a record with bad book 008 is invalid' do
expect(MarcCleanup.bad_008?(record)).to eq true
end
end
let(:leader) { '01104naa a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'knows that a record with bad book 008 is invalid' do
expect(MarcCleanup.bad_008?(record)).to eq true
describe 'bad computer format 008' do
let(:fields) do
[
{ '008' => '230519s1996 njua u 000 0 eng d' }
]
end
let(:leader) { '01104nma a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'knows that a record with bad computer 008 is invalid' do
expect(MarcCleanup.bad_008?(record)).to eq true
end
end
end
describe 'bad computer format 008' do
let(:fields) do
[
{ '008' => '230519s1996 njua u 000 0 eng d' }
]
describe 'bad map format 008' do
let(:fields) do
[
{ '008' => '230519s1996 njua u 000 0 eng d' }
]
end
let(:leader) { '01104nea a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'knows that a record with bad map 008 is invalid' do
expect(MarcCleanup.bad_008?(record)).to eq true
end
end
let(:leader) { '01104nma a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'knows that a record with bad computer 008 is invalid' do
expect(MarcCleanup.bad_008?(record)).to eq true
describe 'bad music format 008' do
let(:fields) do
[
{ '008' => '230519s1996 njua u 000 0 eng d' }
]
end
let(:leader) { '01104nca a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'knows that a record with bad music 008 is invalid' do
expect(MarcCleanup.bad_008?(record)).to eq true
end
end
end
describe 'bad map format 008' do
let(:fields) do
[
{ '008' => '230519s1996 njua u 000 0 eng d' }
]
describe 'bad continuing resource format 008' do
let(:fields) do
[
{ '008' => '230519s1996 njua u 000 0 eng d' }
]
end
let(:leader) { '01104nab a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'knows that a record with bad continuing resource 008 is invalid' do
expect(MarcCleanup.bad_008?(record)).to eq true
end
end
let(:leader) { '01104nea a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'knows that a record with bad map 008 is invalid' do
expect(MarcCleanup.bad_008?(record)).to eq true
describe 'bad visual format 008' do
let(:fields) do
[
{ '008' => '230519s1996 njua u 000 0 eng d' }
]
end
let(:leader) { '01104nga a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'knows that a record with bad visual 008 is invalid' do
expect(MarcCleanup.bad_008?(record)).to eq true
end
end
describe 'bad mix_mat format 008' do
let(:fields) do
[
{ '008' => '230519s1996 njua u 000 0 eng d' }
]
end
let(:leader) { '01104npa a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'knows that a record with bad mix_mat 008 is invalid' do
expect(MarcCleanup.bad_008?(record)).to eq true
end
end
end
describe 'bad music format 008' do
let(:fields) do
[
{ '008' => '230519s1996 njua u 000 0 eng d' }
]
describe 'fix_008' do
describe 'fix_book_008' do
let(:fields) do
[
{ '008' => '230519s1996 njuax 000 0 eng a' }
]
end
let(:leader) { '01104naa a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'corrects a bad book format 008' do
expect(fix_008(record)['008'].value).to eq '230519s1996 njua 000 0 eng '
end
end
let(:leader) { '01104nca a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'knows that a record with bad music 008 is invalid' do
expect(MarcCleanup.bad_008?(record)).to eq true
describe 'fix_comp_008' do
let(:fields) do
[
{ '008' => '230519s1996 njua 000 0 eng o' }
]
end
let(:leader) { '01104nma a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'corrects a bad computer format 008' do
expect(fix_008(record)['008'].value).to eq '230519s1996 nju eng d'
end
end
end
describe 'bad continuing resource format 008' do
let(:fields) do
[
{ '008' => '230519s1996 njua u 000 0 eng d' }
]
describe 'fix_map_008' do
let(:fields) do
[
{ '008' => '230519s1996 njua 000 0 eng d' }
]
end
let(:leader) { '01104nea a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'corrects a bad map format 008' do
expect(fix_008(record)['008'].value).to eq '230519s1996 njua 0 0 eng d'
end
end
let(:leader) { '01104nab a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'knows that a record with bad continuing resource 008 is invalid' do
expect(MarcCleanup.bad_008?(record)).to eq true
describe 'fix_music_008' do
let(:fields) do
[
{ '008' => '230519s1996 njua 000 0 eng d' }
]
end
let(:leader) { '01104nca a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'corrects a bad music format 008' do
expect(fix_008(record)['008'].value).to eq '230519s1996 njua 0 eng d'
end
end
describe 'fix_continuing_resource_008' do
let(:fields) do
[
{ '008' => '230519s1996 njua 000 0 eng d' }
]
end
let(:leader) { '01104nab a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'corrects a bad continuing resource format 008' do
expect(fix_008(record)['008'].value).to eq '230519s1996 njua 0 0 eng d'
end
end
end
describe 'bad visual format 008' do
let(:fields) do
[
{ '008' => '230519s1996 njua u 000 0 eng d' }
]
describe 'fix_visual_008' do
let(:fields) do
[
{ '008' => '230519s1996 njua 000 0 eng d' }
]
end
let(:leader) { '01104nga a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'corrects a bad visual format 008' do
expect(fix_008(record)['008'].value).to eq '230519s1996 njua 0 0neng d'
end
end
let(:leader) { '01104nga a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'knows that a record with bad visual 008 is invalid' do
expect(MarcCleanup.bad_008?(record)).to eq true
describe 'fix_mix_mat_008' do
let(:fields) do
[
{ '008' => '230519s1996 njua 000 0 eng d' }
]
end
let(:leader) { '01104npa a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'corrects a bad mixed materials format 008' do
expect(fix_008(record)['008'].value).to eq '230519s1996 nju eng d'
end
end
describe 'specified 008' do
let(:fields) do
[
{ '008' => '230519s1996 njua 000 0 eng d' }
]
end
let(:leader) { '01104nja a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'corrects a bad specified 008' do
expect(fix_008(record)['008'].value).to eq '230519s1996 njua 0 eng d'
end
end
end
describe 'bad mix_mat format 008' do
describe 'bad_008_length?' do
let(:fields) do
[
{ '008' => '230519s1996 njua u 000 0 eng d' }
{ '008' => '230519s1996 njua 000 0 eng a' }
]
end
let(:leader) { '01104npa a2200289 i 4500' }
let(:leader) { '01104naa a2200289 i 4500' }
let(:record) { MARC::Record.new_from_hash('fields' => fields, 'leader' => leader) }
it 'knows that a record with bad mix_mat 008 is invalid' do
expect(MarcCleanup.bad_008?(record)).to eq true
it 'knows a 008 length is wrong' do
expect(bad_008_length?(record)).to eq true
end
end
end
end

0 comments on commit 9aea23c

Please sign in to comment.