Skip to content

Commit

Permalink
Merge pull request #23 from UNC-Libraries/APPDEV-9947-holdings-factories
Browse files Browse the repository at this point in the history
APPDEV-9947 add factories
  • Loading branch information
ldss-jm authored Mar 8, 2023
2 parents 3b4df0a + a6c26e6 commit f8a6cd0
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/sierra_postgres_utilities/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Sierra
VERSION = '0.3.4'.freeze
VERSION = '0.3.5'.freeze
end
8 changes: 4 additions & 4 deletions spec/data/fields/leaderfield_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
expect(subject.length).to eq(24)
end

it 'uses dummy values for record length (ldr/00-04)' do
it 'uses pseudo values for record length (ldr/00-04)' do
expect(subject[0..4]).to eq('00000')
end

it 'uses dummy values for indicator count (ldr/10)' do
it 'uses pseudo values for indicator count (ldr/10)' do
expect(subject[10]).to eq('2')
end

it 'uses dummy values for subfield code count (ldr/11)' do
it 'uses pseudo values for subfield code count (ldr/11)' do
expect(subject[11]).to eq('2')
end

it 'uses dummy values for misc tail values (ldr/20-23)' do
it 'uses pseudo values for misc tail values (ldr/20-23)' do
expect(subject[20..23]).to eq('4500')
end
end
Expand Down
3 changes: 2 additions & 1 deletion spec/data/fields/varfield_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
expect(v245.to_marc).to eq(
MARC::DataField.new('245', '1', '0',
['a', 'Something else :'],
['b', 'a novel'])
['b', 'a novel /'],
['c', 'Virginia Fassnidge.'])
)
end
end
Expand Down
16 changes: 13 additions & 3 deletions spec/data/helpers/sierra_marc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,21 @@ module Helpers
expect(bib.marc).to be_a(MARC::Record)
end

it 'contains correct marc fields' do
expect(bib.marc.fields).to eq(correct_mrc.fields)
it 'contains correct marc fields', :aggregate_failures do
marc_bib = newrec(Sierra::Data::Bib, build(:metadata_b), build(:data_b))
marc_bib.set_data(:control_fields, [build(:control_008)])
marc_bib.set_data(
:varfields,
[build(:varfield_001), build(:varfield_005), build(:varfield_245),
]
)
expect(marc_bib.marc['001'].to_s).to eq('001 8671134')
expect(marc_bib.marc['005'].to_s).to eq('005 19820807000000.0')
expect(marc_bib.marc['008'].to_s).to eq('008 140912n| azannaabn |n aaa ')
expect(marc_bib.marc['245'].to_s).to eq('245 10 $a Something else : $b a novel / $c Virginia Fassnidge. ')
end

it 'returns proper leader, apart from dummied fields/chars' do
it 'returns proper leader, apart from pseudo-value fields/chars' do
bib.marc.leader[0..4] = '00000'
bib.marc.leader[12..16] = '00000'
correct_mrc.leader[0..4] = '00000'
Expand Down
3 changes: 3 additions & 0 deletions spec/data/record/item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@

describe '#location_desc' do
it 'returns location description / longname' do
location = build(:loc_trln)
location.instance_variable_set(:@name, 'Library Service Center — Request from Storage')
item.set_data(:location, location)
expect(
item.location_desc
).to eq('Library Service Center — Request from Storage')
Expand Down
20 changes: 20 additions & 0 deletions spec/factories/holdings_card.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module Sierra
module Data
FactoryBot.define do
factory :holdings_card, class: HoldingsCard do
id { 26716 }
holding_record_id { 425206860854 }
status_code { 'C' }
display_format_code { nil }
is_suppress_opac_display { nil }
order_record_metadata_id { nil }
is_create_item { false }
is_usmarc { true }
is_marc { nil }
is_use_default_enum { nil }
is_use_default_date { nil }
update_method_code { 'n' }
end
end
end
end
4 changes: 4 additions & 0 deletions spec/factories/location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ module Data
code { 'ddda' }
end

factory :loc_trln do
code { 'trln' }
end

factory :loc_wbba do
code { 'wbba' }
end
Expand Down
12 changes: 12 additions & 0 deletions spec/factories/varfield.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ module Data
field_content { '|aSomething else :|ba novel' }

factory :varfield_245 do
field_content { '|aSomething else :|ba novel /|cVirginia Fassnidge.' }
end

factory :varfield_001 do
marc_tag { '001' }
field_content { '8671134' }
end

factory :varfield_005 do
Expand All @@ -24,6 +30,12 @@ module Data
field_content { '19820807000000.0' }
end

factory :varfield_852 do
marc_tag { '852' }
varfield_type_code { 'c' }
field_content { '|hQV 704|iR388|zEarlier editions in stacks' }
end

factory :varfield_implicit_sfa do
field_content { 'Something else :|ba novel' }
end
Expand Down
7 changes: 0 additions & 7 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
FactoryBot.find_definitions
end

def dummy_set(hsh)
hsh.each do |k, v|
dummy.data.send(:"#{k}=", v)
end
dummy
end

module Sierra
module SpecUtils
module Records
Expand Down

0 comments on commit f8a6cd0

Please sign in to comment.