From f9a3a641c1975553906c050a179a34ec56305a0b Mon Sep 17 00:00:00 2001 From: Chris Colvard Date: Wed, 8 Jul 2020 13:38:11 -0400 Subject: [PATCH] Use paths based on Rails.root instead of pure relative paths --- spec/lib/importer/mods_importer_spec.rb | 6 ++--- spec/lib/importer/mods_parser_spec.rb | 24 +++++++++---------- .../lib/stanford/importer/mods_parser_spec.rb | 4 ++-- .../shared_examples_for_csv_importer.rb | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/spec/lib/importer/mods_importer_spec.rb b/spec/lib/importer/mods_importer_spec.rb index 9265265ca..605616163 100644 --- a/spec/lib/importer/mods_importer_spec.rb +++ b/spec/lib/importer/mods_importer_spec.rb @@ -2,7 +2,7 @@ require 'importer/mods_parser' RSpec.describe Importer::ModsImporter, :clean do - let(:image_directory) { 'spec/fixtures/images' } + let(:image_directory) { File.join(fixture_path, 'images') } let(:importer) { described_class.new(image_directory) } let(:actor) { double } @@ -11,7 +11,7 @@ end describe '#import an image' do - let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' } + let(:file) { File.join(fixture_path, 'mods', 'shpc', 'druid_xv169dn4538.mods') } it 'creates a new image and a collection' do expect(actor).to receive(:create).with(Hyrax::Actors::Environment) do |k| @@ -44,7 +44,7 @@ end describe '#import a Collection' do - let(:file) { 'spec/fixtures/mods/shpc/kx532cb7981.mods' } + let(:file) { File.join(fixture_path, 'mods', 'shpc', 'kx532cb7981.mods') } it 'creates a collection' do coll = nil diff --git a/spec/lib/importer/mods_parser_spec.rb b/spec/lib/importer/mods_parser_spec.rb index d52373388..4870aa5df 100644 --- a/spec/lib/importer/mods_parser_spec.rb +++ b/spec/lib/importer/mods_parser_spec.rb @@ -6,7 +6,7 @@ describe 'Determine which kind of record it is:' do describe 'for a collection:' do - let(:file) { 'spec/fixtures/mods/shpc/kx532cb7981.mods' } + let(:file) { File.join(fixture_path, 'mods', 'shpc', 'kx532cb7981.mods') } it 'knows it is a Collection' do expect(parser.collection?).to eq true @@ -16,7 +16,7 @@ end describe 'for an image:' do - let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' } + let(:file) { File.join(fixture_path, 'mods', 'shpc', 'druid_xv169dn4538.mods') } it 'knows it is an Image' do expect(parser.image?).to eq true @@ -28,7 +28,7 @@ describe '#attributes for an Image record' do let(:ns_decl) { "xmlns='#{Mods::MODS_NS}'" } - let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' } + let(:file) { File.join(fixture_path, 'mods', 'shpc', 'druid_xv169dn4538.mods') } it 'finds metadata for the image' do expect(attributes[:description]).to eq [] @@ -50,7 +50,7 @@ end context 'with a file that has a general (untyped) note' do - let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' } + let(:file) { File.join(fixture_path, 'mods', 'shpc', 'druid_xv169dn4538.mods') } it 'imports notes' do expect(attributes[:notes_attributes].first[:value]).to start_with( @@ -60,7 +60,7 @@ end context 'with a file that has a publisher', skip: "need a record with originInfo" do - let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' } + let(:file) { File.join(fixture_path, 'mods', 'shpc', 'druid_xv169dn4538.mods') } it 'imports publisher' do expect(attributes[:publisher]).to eq ['[Cross & Dimmit Pictures]'] @@ -68,7 +68,7 @@ end context 'with a file that has a photographer', skip: "we're not doing relators beyond contributor" do - let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' } + let(:file) { File.join(fixture_path, 'mods', 'shpc', 'druid_xv169dn4538.mods') } it 'imports photographer' do expect(attributes[:photographer]).to eq ['http://id.loc.gov/authorities/names/n97003180'] @@ -94,7 +94,7 @@ end context 'with a file that has coordinates', skip: 'Need metadata with geo data' do - let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' } + let(:file) { File.join(fixture_path, 'mods', 'shpc', 'druid_xv169dn4538.mods') } it 'imports coordinates' do expect(attributes[:latitude]).to eq ['34.442982'] @@ -134,7 +134,7 @@ end context 'with a file that has a range of dateIssued', skip: "no dates on this record" do - let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' } + let(:file) { File.join(fixture_path, 'mods', 'shpc', 'druid_xv169dn4538.mods') } it 'imports issued' do expect(attributes[:issued_attributes]).to eq [ @@ -148,7 +148,7 @@ end context 'with a file that has a single dateIssued', skip: "no dates on this record" do - let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' } + let(:file) { File.join(fixture_path, 'mods', 'shpc', 'druid_xv169dn4538.mods') } it 'imports issued' do expect(attributes[:issued_attributes]).to eq [ @@ -200,7 +200,7 @@ end context 'with a file that has an alternative title', skip: "Need a record with alt title" do - let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' } + let(:file) { File.join(fixture_path, 'mods', 'shpc', 'druid_xv169dn4538.mods') } it 'distinguishes between title and alternative title' do expect(attributes[:title]).to eq ['Stanford residences -- Sacramento -- Muybridge'] @@ -209,7 +209,7 @@ end context 'with a file that has placeTerm', skip: 'file has no originInfo' do - let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' } + let(:file) { File.join(fixture_path, 'mods', 'shpc', 'druid_xv169dn4538.mods') } it 'reads the place' do expect(attributes[:place_of_publication]). to eq ['Santa Barbara, California'] @@ -218,7 +218,7 @@ end describe '#attributes for a Collection record' do - let(:file) { 'spec/fixtures/mods/shpc/kx532cb7981.mods' } + let(:file) { File.join(fixture_path, 'mods', 'shpc', 'kx532cb7981.mods') } it 'finds the metadata' do expect(attributes[:title]).to eq ['Stanford historical photograph collection, 1887-circa 1996 (inclusive)'] diff --git a/spec/lib/stanford/importer/mods_parser_spec.rb b/spec/lib/stanford/importer/mods_parser_spec.rb index 94ff41d11..01870f9af 100644 --- a/spec/lib/stanford/importer/mods_parser_spec.rb +++ b/spec/lib/stanford/importer/mods_parser_spec.rb @@ -6,7 +6,7 @@ let(:attributes) { parser.attributes } describe '#collection_attributes' do - let(:file) { 'spec/fixtures/mods/shpc/kx532cb7981.mods' } + let(:file) { File.join(fixture_path, 'mods', 'shpc', 'kx532cb7981.mods') } subject { parser.collection_attributes } @@ -16,7 +16,7 @@ end describe '#record_attributes' do - let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' } + let(:file) { File.join(fixture_path, 'mods', 'shpc', 'druid_xv169dn4538.mods') } subject { parser.record_attributes } diff --git a/spec/support/shared_examples_for_csv_importer.rb b/spec/support/shared_examples_for_csv_importer.rb index b4e15a7b4..6ad06a8bf 100644 --- a/spec/support/shared_examples_for_csv_importer.rb +++ b/spec/support/shared_examples_for_csv_importer.rb @@ -7,7 +7,7 @@ file: ["world.png"] } end - let(:factory) { described_class.new(attributes, 'spec/fixtures/images') } + let(:factory) { described_class.new(attributes, File.join(fixture_path, 'images')) } before { factory.run } @@ -27,7 +27,7 @@ end it "updates metadata" do - new_factory = described_class.new(new_attr, 'spec/fixtures/images') + new_factory = described_class.new(new_attr, File.join(fixture_path, 'images')) new_factory.run expect(work.last.title).to eq(["Squid tofu banjo"]) end