|
3 | 3 | require 'rails_helper'
|
4 | 4 |
|
5 | 5 | RSpec.describe Sword::Mets::ProquestEtdXmlDataElement do
|
6 |
| - let(:xpath_info) do |
7 |
| - { namespace: { 'etdsword' => 'http://www.etdadmin.com/ns/etdsword' }, |
8 |
| - abstract: '//etdsword:DISS_abstract', |
9 |
| - author_name: '//etdsword:DISS_author/etdsword:DISS_name', |
10 |
| - first_name: 'etdsword:DISS_fname', |
11 |
| - middle_name: 'etdsword:DISS_middle', |
12 |
| - subjects: '//etdsword:DISS_cat_desc', |
13 |
| - surname: 'etdsword:DISS_surname', |
14 |
| - title: '//etdsword:DISS_title' } |
| 6 | + let(:pq_xml_data) { described_class.new(@xml_data_proquest, Sword::Mets::ProquestConstants::XPATH_INFO) } |
| 7 | + |
| 8 | + let(:author_attrs) { { first_name: 'Ariana', middle_name: 'Cecilia', last_name: 'Gavin', role: 'author' } } |
| 9 | + let(:expected_first_author) { Sword::Metadata::PersonalName.new(author_attrs) } |
| 10 | + |
| 11 | + let(:advisor_attrs) { { first_name: 'Henry', middle_name: 'M', last_name: 'Colecraft', role: 'advisor' } } |
| 12 | + let(:expected_first_advisor) { Sword::Metadata::PersonalName.new(advisor_attrs) } |
| 13 | + |
| 14 | + before(:context) do |
| 15 | + @pq_mets_file = Sword::Mets::MetsFile.new(file_fixture('xml/mets/PQ_mets.xml').read) |
| 16 | + # @xml_data_proquest = @pq_mets_file.find_md_wrap_xml_data_elements(mdtype: 'OTHER', other_mdtype: 'PROQUEST') |
| 17 | + @xml_data_proquest = @pq_mets_file.find_md_wrap_xml_data_element(mdtype: 'OTHER', other_mdtype: 'PROQUEST') |
| 18 | + end |
| 19 | + |
| 20 | + it 'sets the abstract correctly' do |
| 21 | + expect(pq_xml_data.abstract).to include('relief of Rad inhibition of cardiac') |
| 22 | + end |
| 23 | + |
| 24 | + it 'sets the title correctly' do |
| 25 | + expect(pq_xml_data.title).to include('Unraveling the logic') |
| 26 | + end |
| 27 | + |
| 28 | + it 'sets the subjects correctly' do |
| 29 | + expect(pq_xml_data.instance_variable_get(:@subjects)).to be_nil |
| 30 | + expect(pq_xml_data.subjects).to contain_exactly('Molecular biology', 'Pharmacology', 'Physiology') |
15 | 31 | end
|
16 | 32 |
|
17 |
| - describe 'at initialization' do |
18 |
| - before(:context) do |
19 |
| - @pq_mets_file = Sword::Mets::MetsFile.new(file_fixture('xml/mets/PQ_mets.xml').read) |
20 |
| - # @xml_data_proquest = @pq_mets_file.find_md_wrap_xml_data_elements(mdtype: 'OTHER', other_mdtype: 'PROQUEST') |
21 |
| - @xml_data_proquest = @pq_mets_file.find_md_wrap_xml_data_element(mdtype: 'OTHER', other_mdtype: 'PROQUEST') |
22 |
| - end |
23 |
| - |
24 |
| - it 'sets the abstract correctly' do |
25 |
| - pq_xml_data = described_class.new(@xml_data_proquest, xpath_info) |
26 |
| - expect(pq_xml_data.abstract).to include('relief of Rad inhibition of cardiac') |
27 |
| - end |
28 |
| - |
29 |
| - it 'sets the title correctly' do |
30 |
| - pq_xml_data = described_class.new(@xml_data_proquest, xpath_info) |
31 |
| - expect(pq_xml_data.title).to include('Unraveling the logic') |
32 |
| - end |
| 33 | + it 'sets the authors correctly' do |
| 34 | + expect(pq_xml_data.instance_variable_get(:@authors)).to be_nil |
| 35 | + expect(pq_xml_data.authors.first.attributes).to eql(expected_first_author.attributes) |
33 | 36 | end
|
34 | 37 |
|
35 |
| - describe 'after parsing' do |
36 |
| - before(:context) do |
37 |
| - @pq_mets_file = Sword::Mets::MetsFile.new(file_fixture('xml/mets/PQ_mets.xml').read) |
38 |
| - # @xml_data_proquest = @pq_mets_file.find_md_wrap_xml_data_elements(mdtype: 'OTHER', other_mdtype: 'PROQUEST') |
39 |
| - @xml_data_proquest = @pq_mets_file.find_md_wrap_xml_data_element(mdtype: 'OTHER', other_mdtype: 'PROQUEST') |
40 |
| - end |
41 |
| - |
42 |
| - it 'sets the subjects correctly' do |
43 |
| - pq_xml_data = described_class.new(@xml_data_proquest, xpath_info) |
44 |
| - pq_xml_data.parse_subjects |
45 |
| - expect(pq_xml_data.subjects).to include('Molecular biology') |
46 |
| - expect(pq_xml_data.subjects).to include('Pharmacology') |
47 |
| - expect(pq_xml_data.subjects).to include('Physiology') |
48 |
| - end |
49 |
| - |
50 |
| - it 'sets the authors correctly' do |
51 |
| - pq_xml_data = described_class.new(@xml_data_proquest, xpath_info) |
52 |
| - pq_xml_data.parse_authors |
53 |
| - expect(pq_xml_data.authors.first.first_name).to include('Ariana') |
54 |
| - expect(pq_xml_data.authors.first.middle_name).to include('Cecilia') |
55 |
| - expect(pq_xml_data.authors.first.last_name).to include('Gavin') |
56 |
| - end |
| 38 | + it 'sets the advisors correctly' do |
| 39 | + expect(pq_xml_data.advisors.first.attributes).to eql(expected_first_advisor.attributes) |
57 | 40 | end
|
58 | 41 | end
|
0 commit comments