active-fedora 11.0.0.rc1 → 11.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/lib/active_fedora/railtie.rb +2 -2
  3. data/lib/active_fedora/version.rb +1 -1
  4. data/spec/integration/associations_spec.rb +17 -18
  5. data/spec/integration/attached_files_spec.rb +4 -4
  6. data/spec/integration/attributes_spec.rb +12 -16
  7. data/spec/integration/autosave_association_spec.rb +5 -5
  8. data/spec/integration/base_spec.rb +2 -2
  9. data/spec/integration/collection_association_spec.rb +2 -5
  10. data/spec/integration/datastream_rdf_nested_attributes_spec.rb +23 -23
  11. data/spec/integration/date_time_properties_spec.rb +1 -2
  12. data/spec/integration/direct_container_spec.rb +8 -8
  13. data/spec/integration/directly_contains_one_association_spec.rb +11 -13
  14. data/spec/integration/fedora_solr_sync_spec.rb +2 -2
  15. data/spec/integration/file_fixity_spec.rb +6 -8
  16. data/spec/integration/file_spec.rb +9 -10
  17. data/spec/integration/has_many_associations_spec.rb +6 -8
  18. data/spec/integration/indirect_container_spec.rb +8 -9
  19. data/spec/integration/json_serialization_spec.rb +4 -4
  20. data/spec/integration/ntriples_datastream_spec.rb +74 -74
  21. data/spec/integration/om_datastream_spec.rb +13 -13
  22. data/spec/integration/rdf_nested_attributes_spec.rb +6 -6
  23. data/spec/integration/relation_delegation_spec.rb +8 -8
  24. data/spec/integration/relation_spec.rb +13 -16
  25. data/spec/integration/solr_hit_spec.rb +4 -4
  26. data/spec/integration/versionable_spec.rb +132 -132
  27. data/spec/unit/aggregation/list_source_spec.rb +37 -37
  28. data/spec/unit/aggregation/ordered_reader_spec.rb +4 -4
  29. data/spec/unit/association_hash_spec.rb +15 -15
  30. data/spec/unit/attached_files_spec.rb +19 -19
  31. data/spec/unit/attributes_spec.rb +25 -25
  32. data/spec/unit/base_active_model_spec.rb +8 -8
  33. data/spec/unit/base_extra_spec.rb +5 -4
  34. data/spec/unit/base_spec.rb +9 -9
  35. data/spec/unit/change_set_spec.rb +5 -5
  36. data/spec/unit/core_spec.rb +26 -26
  37. data/spec/unit/default_model_mapper_spec.rb +3 -3
  38. data/spec/unit/fedora_spec.rb +2 -2
  39. data/spec/unit/file_configurator_spec.rb +92 -92
  40. data/spec/unit/file_spec.rb +60 -60
  41. data/spec/unit/files_hash_spec.rb +7 -7
  42. data/spec/unit/has_and_belongs_to_many_association_spec.rb +12 -12
  43. data/spec/unit/has_many_association_spec.rb +2 -2
  44. data/spec/unit/indexers/global_indexer_spec.rb +6 -6
  45. data/spec/unit/indexing_service_spec.rb +5 -5
  46. data/spec/unit/indexing_spec.rb +4 -4
  47. data/spec/unit/loadable_from_json_spec.rb +4 -4
  48. data/spec/unit/model_classifier_spec.rb +4 -4
  49. data/spec/unit/nom_datastream_spec.rb +8 -8
  50. data/spec/unit/om_datastream_spec.rb +43 -43
  51. data/spec/unit/ordered_spec.rb +142 -142
  52. data/spec/unit/orders/list_node_spec.rb +20 -20
  53. data/spec/unit/orders/ordered_list_spec.rb +96 -96
  54. data/spec/unit/orders/reflection_spec.rb +3 -3
  55. data/spec/unit/pathing_spec.rb +4 -4
  56. data/spec/unit/persistence_spec.rb +28 -28
  57. data/spec/unit/qualified_dublin_core_datastream_spec.rb +8 -8
  58. data/spec/unit/query_spec.rb +5 -5
  59. data/spec/unit/rdf/indexing_service_spec.rb +17 -17
  60. data/spec/unit/rdf_datastream_spec.rb +10 -10
  61. data/spec/unit/rdf_resource_datastream_spec.rb +37 -37
  62. data/spec/unit/rdfxml_datastream_spec.rb +14 -14
  63. data/spec/unit/readonly_spec.rb +5 -4
  64. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +9 -9
  65. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +9 -9
  66. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +9 -9
  67. data/spec/unit/schema_indexing_strategy_spec.rb +5 -5
  68. data/spec/unit/serializers_spec.rb +3 -4
  69. data/spec/unit/solr_hit_spec.rb +9 -9
  70. data/spec/unit/sparql_insert_spec.rb +2 -2
  71. data/spec/unit/validations_spec.rb +9 -9
  72. data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +2 -1
  73. data/spec/unit/with_metadata/metadata_node_spec.rb +3 -2
  74. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e30d9865f03aa8fde7431fa449c1fd1b0fa8a3c5
4
- data.tar.gz: ad33f54129ac32831e5917b980d2607e2fd6bc1d
3
+ metadata.gz: 4b833ffd608a93150c266715fe4a7407b4123226
4
+ data.tar.gz: 3eb0722fd8dd81dba86b8de505859e464a321145
5
5
  SHA512:
6
- metadata.gz: edf50b69bdd72334819f4470868936646752c79da2091413721ea35410ce45ec00e14445f8853df15f36fa18fff89dfe443b3171985395b910237f7de54531e7
7
- data.tar.gz: 09720448439264991177243424a6f9bf1d133c62ad916b00d9075d22ab04625b6548d6a166883ae229c1509e7cf5c4fd85ee1466b7b2d05bbc45ba8a76a3ccb4
6
+ metadata.gz: 6956d0ea72523e17d0ae7b856565f8abab7a20f9247e3fe6a410ec56c0227468a1aa242148cf10f91d6ca47279b798b04b203fb161a5b38b2ff0dd5e4879e310
7
+ data.tar.gz: c9202017657e945638899468958d79205fc7cbe44e41b5638347a3363a61cd24e23d4e0b81ad8781faa9f0a48e3da30804f5d8453c62d1d2cbaaca8dec762dab
@@ -1,7 +1,7 @@
1
1
  module ActiveFedora
2
2
  class Railtie < Rails::Railtie
3
- config.app_middleware.insert_after "::ActionDispatch::Callbacks",
4
- "ActiveFedora::LdpCache"
3
+ config.app_middleware.insert_after ::ActionDispatch::Callbacks,
4
+ ActiveFedora::LdpCache
5
5
 
6
6
  initializer 'active_fedora.autoload', before: :set_autoload_paths do |app|
7
7
  app.config.autoload_paths << 'app/models/datastreams'
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "11.0.0.rc1".freeze
2
+ VERSION = "11.0.0.rc2".freeze
3
3
  end
@@ -17,7 +17,7 @@ describe ActiveFedora::Base do
17
17
  end
18
18
 
19
19
  let(:person) { Person.create }
20
- let(:book) { Book.new(author: person) }
20
+ subject(:book) { Book.new(author: person) }
21
21
 
22
22
  it "goes" do
23
23
  book.save
@@ -524,18 +524,19 @@ describe ActiveFedora::Base do
524
524
  end
525
525
 
526
526
  describe "removing association" do
527
- subject { LibraryBook.create }
528
- before do
529
- @p1 = Page.create
530
- @p2 = Page.create
531
- subject.pages << @p1 << @p2
532
- subject.save!
527
+ let(:p1) { Page.create }
528
+ let(:p2) { Page.create }
529
+ subject(:book) do
530
+ book = LibraryBook.create
531
+ book.pages << p1 << p2
532
+ book.save!
533
+ book
533
534
  end
534
535
  it "saves between the before and after hooks" do
535
- expect(subject).to receive(:before_count).with(1)
536
- expect(subject).to receive(:after_count).with(0)
537
- expect(subject).to receive(:say_hi).with(@p2).twice
538
- subject.pages.delete(@p2)
536
+ expect(book).to receive(:before_count).with(1)
537
+ expect(book).to receive(:after_count).with(0)
538
+ expect(book).to receive(:say_hi).with(p2).twice
539
+ book.pages.delete(p2)
539
540
  end
540
541
  end
541
542
  end
@@ -555,14 +556,12 @@ describe ActiveFedora::Base do
555
556
  end
556
557
 
557
558
  describe "removing association" do
558
- subject { LibraryBook.new }
559
- before do
560
- @p1 = subject.pages.build
561
- @p2 = subject.pages.build
562
- end
559
+ let(:p1) { book.pages.build }
560
+ let(:p2) { book.pages.build }
561
+ let(:book) { LibraryBook.new }
563
562
  it "runs the hooks" do
564
- expect(subject).to receive(:say_hi).with(@p2)
565
- subject.pages.delete(@p2)
563
+ expect(book).to receive(:say_hi).with(p2)
564
+ book.pages.delete(p2)
566
565
  end
567
566
  end
568
567
  end
@@ -65,14 +65,14 @@ describe ActiveFedora::AttachedFiles do
65
65
  let(:obj) { ActiveFedora::Base.new }
66
66
 
67
67
  describe ".attached_files" do
68
- subject { obj.attached_files }
68
+ subject(:attached_files) { obj.attached_files }
69
69
  it "returns a Hash of datastreams from fedora" do
70
- expect(subject).to be_a_kind_of(ActiveFedora::FilesHash)
71
- expect(subject).to be_empty
70
+ expect(attached_files).to be_a_kind_of(ActiveFedora::FilesHash)
71
+ expect(attached_files).to be_empty
72
72
  end
73
73
 
74
74
  it "initializes the datastream pointers with @new_object=false" do
75
- subject.each_value do |ds|
75
+ attached_files.each_value do |ds|
76
76
  expect(ds).to_not be_new
77
77
  end
78
78
  end
@@ -20,9 +20,9 @@ describe "delegating attributes" do
20
20
 
21
21
  describe "#index_config" do
22
22
  context "on a class with properties" do
23
- subject { RdfObject.index_config }
23
+ subject(:index_config) { RdfObject.index_config }
24
24
  it "has configuration" do
25
- expect(subject[:resource_type].behaviors).to eq [:stored_searchable, :facetable]
25
+ expect(index_config[:resource_type].behaviors).to eq [:stored_searchable, :facetable]
26
26
  end
27
27
  end
28
28
 
@@ -36,42 +36,38 @@ describe "delegating attributes" do
36
36
  Object.send(:remove_const, :InheritedObject)
37
37
  end
38
38
 
39
- subject { InheritedObject.index_config }
39
+ subject(:index_config) { InheritedObject.index_config }
40
40
 
41
41
  it "has configuration" do
42
- expect(subject[:resource_type].behaviors).to eq [:stored_searchable, :facetable]
42
+ expect(index_config[:resource_type].behaviors).to eq [:stored_searchable, :facetable]
43
43
  end
44
44
 
45
45
  context "when the inherited config is modifed" do
46
46
  before do
47
47
  InheritedObject.index_config[:resource_type].behaviors.delete(:stored_searchable)
48
48
  end
49
- subject { RdfObject.index_config }
49
+ subject(:index_config) { RdfObject.index_config }
50
50
 
51
51
  it "the parent config is unchanged" do
52
- expect(subject[:resource_type].behaviors).to eq [:stored_searchable, :facetable]
52
+ expect(index_config[:resource_type].behaviors).to eq [:stored_searchable, :facetable]
53
53
  end
54
54
  end
55
55
  end
56
56
  end
57
57
 
58
58
  describe "previous_changes" do
59
- subject do
60
- TitledObject.create(title: ["Hydra for Dummies"])
61
- end
59
+ subject(:titled_object) { TitledObject.create(title: ["Hydra for Dummies"]) }
62
60
  it "keeps a list of changes after a successful save" do
63
- expect(subject.previous_changes).to_not be_empty
64
- expect(subject.previous_changes.keys).to include("title")
61
+ expect(titled_object.previous_changes).to_not be_empty
62
+ expect(titled_object.previous_changes.keys).to include("title")
65
63
  end
66
64
  end
67
65
 
68
66
  describe "#changes" do
69
- subject do
70
- TitledObject.create(title: ["Hydra for Dummies"])
71
- end
67
+ let(:titled_object) { TitledObject.create(title: ["Hydra for Dummies"]) }
72
68
  it "cleans out changes" do
73
- expect(subject).to_not be_title_changed
74
- expect(subject.changes).to be_empty
69
+ expect(titled_object).to_not be_title_changed
70
+ expect(titled_object.changes).to be_empty
75
71
  end
76
72
  end
77
73
  end
@@ -9,16 +9,16 @@ describe ActiveFedora::Base do
9
9
  Object.send(:remove_const, :MockAFBaseRelationship)
10
10
  end
11
11
 
12
- subject { MockAFBaseRelationship.new }
12
+ subject(:relationship) { MockAFBaseRelationship.new }
13
13
 
14
14
  context '#changed_for_autosave?' do
15
15
  before(:each) do
16
- expect(subject).to receive(:new_record?).and_return(false)
17
- expect(subject).to receive(:changed?).and_return(false)
18
- expect(subject).to receive(:marked_for_destruction?).and_return(false)
16
+ expect(relationship).to receive(:new_record?).and_return(false)
17
+ expect(relationship).to receive(:changed?).and_return(false)
18
+ expect(relationship).to receive(:marked_for_destruction?).and_return(false)
19
19
  end
20
20
  it {
21
- expect { subject.changed_for_autosave? }.to_not raise_error
21
+ expect { relationship.changed_for_autosave? }.to_not raise_error
22
22
  }
23
23
  end
24
24
  end
@@ -159,7 +159,7 @@ describe ActiveFedora::Base do
159
159
  end
160
160
 
161
161
  describe "overriding resource_class_factory" do
162
- subject { TestBase.new }
162
+ subject(:test_base) { TestBase.new }
163
163
  before do
164
164
  class TestResource < ActiveTriples::Resource
165
165
  end
@@ -174,7 +174,7 @@ describe ActiveFedora::Base do
174
174
  Object.send(:remove_const, :TestBase)
175
175
  end
176
176
  it "uses that factory for #resource" do
177
- expect(subject.resource.class.ancestors).to include TestResource
177
+ expect(test_base.resource.class.ancestors).to include TestResource
178
178
  end
179
179
  end
180
180
  end
@@ -135,10 +135,9 @@ describe ActiveFedora::Base do
135
135
  end
136
136
 
137
137
  let(:instance) { SpecContainer.new }
138
- subject { instance.items }
139
138
 
140
139
  it "raises an error" do
141
- expect { subject }.to raise_error "No :inverse_of or :predicate attribute was set or could be inferred for has_many :items on SpecContainer"
140
+ expect { instance.items }.to raise_error "No :inverse_of or :predicate attribute was set or could be inferred for has_many :items on SpecContainer"
142
141
  end
143
142
  end
144
143
 
@@ -161,9 +160,7 @@ describe ActiveFedora::Base do
161
160
  let(:instance) { Foo::Container.new }
162
161
  subject { instance.items }
163
162
 
164
- it "finds the association" do
165
- expect(subject).to eq []
166
- end
163
+ it { is_expected.to eq [] }
167
164
  end
168
165
  end
169
166
  end
@@ -60,7 +60,7 @@ describe "Nesting attribute behavior of RDFDatastream" do
60
60
  Object.send(:remove_const, :ComplexRDFDatastream)
61
61
  Object.send(:remove_const, :DummyMADS)
62
62
  end
63
- subject { ComplexRDFDatastream.new }
63
+ subject(:complex_datastream) { ComplexRDFDatastream.new }
64
64
  let(:params) do
65
65
  { myResource:
66
66
  {
@@ -95,15 +95,15 @@ describe "Nesting attribute behavior of RDFDatastream" do
95
95
  end
96
96
 
97
97
  describe "on lists" do
98
- subject { ComplexRDFDatastream::PersonalName.new(nil) }
98
+ subject(:personal_name) { ComplexRDFDatastream::PersonalName.new(nil) }
99
99
  it "accepts a hash" do
100
- subject.elementList_attributes = [{ topicElement_attributes: { '0' => { elementValue: "Quantum Behavior" }, '1' => { elementValue: "Wave Function" } } }]
101
- expect(subject.elementList.first[0].elementValue).to eq ["Quantum Behavior"]
102
- expect(subject.elementList.first[1].elementValue).to eq ["Wave Function"]
100
+ personal_name.elementList_attributes = [{ topicElement_attributes: { '0' => { elementValue: "Quantum Behavior" }, '1' => { elementValue: "Wave Function" } } }]
101
+ expect(personal_name.elementList.first[0].elementValue).to eq ["Quantum Behavior"]
102
+ expect(personal_name.elementList.first[1].elementValue).to eq ["Wave Function"]
103
103
  end
104
104
  it "accepts an array" do
105
- subject.elementList_attributes = [{ topicElement_attributes: [{ elementValue: "Quantum Behavior" }, { elementValue: "Wave Function" }] }]
106
- element_values = subject.elementList.first.map(&:elementValue)
105
+ personal_name.elementList_attributes = [{ topicElement_attributes: [{ elementValue: "Quantum Behavior" }, { elementValue: "Wave Function" }] }]
106
+ element_values = personal_name.elementList.first.map(&:elementValue)
107
107
  expect(element_values).to contain_exactly ["Quantum Behavior"], ["Wave Function"]
108
108
  end
109
109
  end
@@ -111,30 +111,30 @@ describe "Nesting attribute behavior of RDFDatastream" do
111
111
  context "from nested objects" do
112
112
  before do
113
113
  # Replace the graph's contents with the Hash
114
- subject.attributes = params[:myResource]
114
+ complex_datastream.attributes = params[:myResource]
115
115
  end
116
116
 
117
117
  it 'has attributes' do
118
- element_values = subject.topic.map { |x| x.elementList.first[0].elementValue }
118
+ element_values = complex_datastream.topic.map { |x| x.elementList.first[0].elementValue }
119
119
  expect(element_values).to contain_exactly ["Cosmology"], ["Quantum Behavior"]
120
- expect(subject.personalName.first.elementList.first.fullNameElement).to contain_exactly "Jefferson, Thomas"
121
- expect(subject.personalName.first.elementList.first.dateNameElement).to contain_exactly "1743-1826"
120
+ expect(complex_datastream.personalName.first.elementList.first.fullNameElement).to contain_exactly "Jefferson, Thomas"
121
+ expect(complex_datastream.personalName.first.elementList.first.dateNameElement).to contain_exactly "1743-1826"
122
122
  end
123
123
 
124
124
  it 'builds nodes with ids' do
125
- element_list_elements = subject.topic.flat_map { |y| y.elementList.first[0].rdf_subject }
125
+ element_list_elements = complex_datastream.topic.flat_map { |y| y.elementList.first[0].rdf_subject }
126
126
  expect(element_list_elements).to include 'http://library.ucsd.edu/ark:/20775/bb3333333x'
127
- expect(subject.personalName.first.rdf_subject).to eq 'http://library.ucsd.edu/ark:20775/jefferson'
127
+ expect(complex_datastream.personalName.first.rdf_subject).to eq 'http://library.ucsd.edu/ark:20775/jefferson'
128
128
  end
129
129
 
130
130
  it 'fails when writing to a non-predicate' do
131
131
  attributes = { topic_attributes: { '0' => { elementList_attributes: [{ topicElement_attributes: [{ fake_predicate: "Cosmology" }] }] } } }
132
- expect { subject.attributes = attributes }.to raise_error ArgumentError
132
+ expect { complex_datastream.attributes = attributes }.to raise_error ArgumentError
133
133
  end
134
134
 
135
135
  it 'fails when writing to a non-predicate with a setter method' do
136
136
  attributes = { topic_attributes: { '0' => { elementList_attributes: [{ topicElement_attributes: [{ name: "Cosmology" }] }] } } }
137
- expect { subject.attributes = attributes }.to raise_error ArgumentError
137
+ expect { complex_datastream.attributes = attributes }.to raise_error ArgumentError
138
138
  end
139
139
  end
140
140
  end
@@ -154,26 +154,26 @@ describe "Nesting attribute behavior of RDFDatastream" do
154
154
  after(:each) do
155
155
  Object.send(:remove_const, :SpecDatastream)
156
156
  end
157
- subject { SpecDatastream.new }
157
+ subject(:spec_datastream) { SpecDatastream.new }
158
158
  before do
159
- subject.attributes = { parts_attributes: [
159
+ spec_datastream.attributes = { parts_attributes: [
160
160
  { label: 'Alternator' },
161
161
  { label: 'Distributor' },
162
162
  { label: 'Transmission' },
163
163
  { label: 'Fuel Filter' }
164
164
  ] }
165
165
  end
166
- let(:replace_object_id) { subject.parts.find { |x| x.label == ['Distributor'] }.rdf_subject.to_s }
167
- let(:remove_object_id) { subject.parts.find { |x| x.label == ['Fuel Filter'] }.rdf_subject.to_s }
166
+ let(:replace_object_id) { spec_datastream.parts.find { |x| x.label == ['Distributor'] }.rdf_subject.to_s }
167
+ let(:remove_object_id) { spec_datastream.parts.find { |x| x.label == ['Fuel Filter'] }.rdf_subject.to_s }
168
168
 
169
169
  it "updates nested objects" do
170
- subject.parts_attributes = [{ id: replace_object_id, label: "Universal Joint" }, { label: "Oil Pump" }, { id: remove_object_id, _destroy: '1', label: "bar1 uno" }]
170
+ spec_datastream.parts_attributes = [{ id: replace_object_id, label: "Universal Joint" }, { label: "Oil Pump" }, { id: remove_object_id, _destroy: '1', label: "bar1 uno" }]
171
171
 
172
- expect(subject.parts.map { |p| p.label.first }).to contain_exactly 'Alternator', 'Universal Joint', 'Transmission', 'Oil Pump'
172
+ expect(spec_datastream.parts.map { |p| p.label.first }).to contain_exactly 'Alternator', 'Universal Joint', 'Transmission', 'Oil Pump'
173
173
  end
174
174
  it "create a new object when the id is provided" do
175
- subject.parts_attributes = [{ id: 'http://example.com/part#1', label: "Universal Joint" }]
176
- expect(subject.parts.map(&:rdf_subject)).to include RDF::URI('http://example.com/part#1')
175
+ spec_datastream.parts_attributes = [{ id: 'http://example.com/part#1', label: "Universal Joint" }]
176
+ expect(spec_datastream.parts.map(&:rdf_subject)).to include RDF::URI('http://example.com/part#1')
177
177
  end
178
178
  end
179
179
  end
@@ -34,9 +34,8 @@ describe ActiveFedora::Base do
34
34
  describe 'serializing' do
35
35
  let(:object) { Foo.new(date: [date]) }
36
36
  let(:triple) { object.resource.query(predicate: ::RDF::Vocab::DC.date).to_a.first }
37
- subject { triple.to_s }
38
37
  it 'time zone must have semicolin to be a cannonical XMLSchema#dateTime' do
39
- expect(subject).to match(/\+01:00/)
38
+ expect(triple.to_s).to match(/\+01:00/)
40
39
  end
41
40
  end
42
41
  end
@@ -32,16 +32,16 @@ describe "Direct containers" do
32
32
  end
33
33
 
34
34
  describe "#first" do
35
- subject { reloaded.files.first }
35
+ subject(:first_file) { reloaded.files.first }
36
36
  it "has the content" do
37
- expect(subject.content).to eq 'HMMM'
37
+ expect(first_file.content).to eq 'HMMM'
38
38
  end
39
39
  end
40
40
 
41
41
  describe "#to_a" do
42
- subject { reloaded.files }
42
+ subject(:files) { reloaded.files }
43
43
  it "has the content" do
44
- expect(subject.to_a).to eq [file]
44
+ expect(files.to_a).to eq [file]
45
45
  end
46
46
  end
47
47
 
@@ -102,9 +102,9 @@ describe "Direct containers" do
102
102
  end
103
103
 
104
104
  describe "#first" do
105
- subject { reloaded.files.first }
105
+ subject(:first_file) { reloaded.files.first }
106
106
  it "has the content" do
107
- expect(subject.content).to eq 'HMMM'
107
+ expect(first_file.content).to eq 'HMMM'
108
108
  end
109
109
  end
110
110
  end
@@ -140,9 +140,9 @@ describe "Direct containers" do
140
140
  end
141
141
 
142
142
  describe "#first" do
143
- subject { reloaded.files.first }
143
+ subject(:first_file) { reloaded.files.first }
144
144
  it "has the content" do
145
- expect(subject.content).to eq 'HMMM'
145
+ expect(first_file.content).to eq 'HMMM'
146
146
  end
147
147
  end
148
148
  end
@@ -36,15 +36,15 @@ describe ActiveFedora::Base do
36
36
  primary_file.content = "I'm in a container all alone!"
37
37
  page_image.save!
38
38
  end
39
- subject { reloaded_page_image.primary_file }
39
+ subject(:reloaded_file) { reloaded_page_image.primary_file }
40
40
  it "initializes an object within the container" do
41
- expect(subject.content).to eq("I'm in a container all alone!")
42
- expect(subject.metadata_node.type).to include(::RDF::URI.new("http://example.com/primaryFile"))
41
+ expect(reloaded_file.content).to eq("I'm in a container all alone!")
42
+ expect(reloaded_file.metadata_node.type).to include(::RDF::URI.new("http://example.com/primaryFile"))
43
43
  end
44
44
  it "relies on info from the :through association, including class_name" do
45
45
  expect(page_image.files).to include(primary_file)
46
46
  expect(primary_file.uri.to_s).to include("/files/")
47
- expect(subject.class).to eq FileWithMetadata
47
+ expect(reloaded_file.class).to eq FileWithMetadata
48
48
  end
49
49
  end
50
50
  end
@@ -61,9 +61,7 @@ describe ActiveFedora::Base do
61
61
  primary_file.content = "I am too"
62
62
  page_image.save!
63
63
  end
64
- it "returns the matching object" do
65
- expect(subject).to eq primary_file
66
- end
64
+ it { is_expected.to eq primary_file }
67
65
  end
68
66
  context "if class_name is set" do
69
67
  before do
@@ -71,10 +69,10 @@ describe ActiveFedora::Base do
71
69
  alternative_file.content = "I am too"
72
70
  page_image.save!
73
71
  end
74
- subject { reloaded_page_image.alternative_file }
72
+ subject(:reloaded_file) { reloaded_page_image.alternative_file }
75
73
  it "uses the specified class to load objects" do
76
- expect(subject).to eq alternative_file
77
- expect(subject).to be_instance_of AlternativeFileWithMetadata
74
+ expect(reloaded_file).to eq alternative_file
75
+ expect(reloaded_file).to be_instance_of AlternativeFileWithMetadata
78
76
  end
79
77
  end
80
78
  end
@@ -85,13 +83,13 @@ describe ActiveFedora::Base do
85
83
  primary_file.content = "I am too"
86
84
  page_image.save!
87
85
  end
88
- subject { reloaded_page_image.files }
86
+ subject(:reloaded_file) { reloaded_page_image.files }
89
87
  it "replaces existing record without disturbing the other contents of the container" do
90
88
  replacement_file = page_image.primary_file = FileWithMetadata.new
91
89
  replacement_file.content = "I'm a replacement"
92
90
  page_image.save
93
- expect(subject).to_not include(primary_file)
94
- expect(subject).to contain_exactly(a_file, replacement_file)
91
+ expect(reloaded_file).to_not include(primary_file)
92
+ expect(reloaded_file).to contain_exactly(a_file, replacement_file)
95
93
  expect(reloaded_page_image.primary_file).to eq(replacement_file)
96
94
  end
97
95
  end