Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional spec tests for fix_008 #84

Merged
merged 7 commits into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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