Sha256: ad2e96dc2814e92ba91c253a5428310879a9f63c498658650d36745f19ee2216

Contents?: true

Size: 1.78 KB

Versions: 3

Compression:

Stored size: 1.78 KB

Contents

# ------------------------------------------------------------
# Simplecov

if ENV['COVERAGE']
  require 'colorize'
  require 'simplecov'
end

# ------------------------------------------------------------
# RSpec

require 'webmock/rspec'

RSpec.configure do |config|
  config.color = true
  config.tty = true
  config.formatter = :documentation
  config.before { WebMock.disable_net_connect!(allow_localhost: true) }
  config.after { WebMock.allow_net_connect! }
  config.mock_with :rspec do |mocks|
    mocks.verify_partial_doubles = true
  end
  config.shared_context_metadata_behavior = :apply_to_host_groups
end

# ------------------------------------------------------------
# Code under test

require 'berkeley_library/av/core'

# ------------------------------------------------------------
# Utility methods

def sru_url_base
  'https://berkeley.alma.exlibrisgroup.com/view/sru/01UCS_BER?version=1.2&operation=searchRetrieve&query='
end

def permalink_base
  'https://search.library.berkeley.edu/permalink/01UCS_BER/iqob43/alma'
end

def alma_sru_url_for(record_id)
  return "#{sru_url_base}alma.mms_id%3D#{record_id}" unless BerkeleyLibrary::AV::RecordId::Type.for_id(record_id) == BerkeleyLibrary::AV::RecordId::Type::MILLENNIUM

  full_bib = BerkeleyLibrary::AV::RecordId.ensure_check_digit(record_id)
  "#{sru_url_base}alma.other_system_number%3DUCB-#{full_bib}-01ucs_ber"
end

def alma_sru_data_path_for(record_id)
  "spec/data/alma/#{record_id}-sru.xml"
end

def stub_sru_request(record_id)
  sru_url = alma_sru_url_for(record_id)
  marc_xml_path = alma_sru_data_path_for(record_id)

  stub_request(:get, sru_url).to_return(status: 200, body: File.read(marc_xml_path))
end

def alma_marc_record_for(record_id)
  marc_xml_path = alma_sru_data_path_for(record_id)
  MARC::XMLReader.new(marc_xml_path).first
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
berkeley_library-av-core-0.4.2 spec/spec_helper.rb
berkeley_library-av-core-0.4.1 spec/spec_helper.rb
berkeley_library-av-core-0.4.0 spec/spec_helper.rb