Skip to content

Commit

Permalink
Use paths based on Rails.root instead of pure relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcolvar committed Jul 8, 2020
1 parent 7821d83 commit f9a3a64
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions spec/lib/importer/mods_importer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand All @@ -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|
Expand Down Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions spec/lib/importer/mods_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 []
Expand All @@ -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(
Expand All @@ -60,15 +60,15 @@
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]']
end
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']
Expand All @@ -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']
Expand Down Expand Up @@ -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 [
Expand All @@ -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 [
Expand Down Expand Up @@ -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']
Expand All @@ -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']
Expand All @@ -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)']
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/stanford/importer/mods_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand All @@ -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 }

Expand Down
4 changes: 2 additions & 2 deletions spec/support/shared_examples_for_csv_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand All @@ -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
Expand Down

0 comments on commit f9a3a64

Please sign in to comment.