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
@@ -6,22 +6,22 @@ describe ActiveFedora::Base do
6
6
  property :fubar, predicate: ::RDF::URI('http://example.com/fubar'), multiple: false
7
7
  property :duck, predicate: ::RDF::URI('http://example.com/duck'), multiple: false
8
8
  end
9
- subject { BarHistory.new }
9
+ subject(:history) { BarHistory.new }
10
10
 
11
11
  describe "attributes=" do
12
12
  it "sets attributes" do
13
- subject.attributes = { fubar: "baz", duck: "Quack" }
14
- expect(subject.fubar).to eq "baz"
15
- expect(subject.duck).to eq "Quack"
13
+ history.attributes = { fubar: "baz", duck: "Quack" }
14
+ expect(history.fubar).to eq "baz"
15
+ expect(history.duck).to eq "Quack"
16
16
  end
17
17
  end
18
18
 
19
19
  describe "update_attributes" do
20
20
  it "sets attributes and save" do
21
- subject.update_attributes(fubar: "baz", duck: "Quack")
22
- subject.reload
23
- expect(subject.fubar).to eq "baz"
24
- expect(subject.duck).to eq "Quack"
21
+ history.update_attributes(fubar: "baz", duck: "Quack")
22
+ history.reload
23
+ expect(history.fubar).to eq "baz"
24
+ expect(history.duck).to eq "Quack"
25
25
  end
26
26
  end
27
27
  end
@@ -1,6 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::Base do
4
+ subject(:object) { described_class.new }
4
5
  describe ".update_index" do
5
6
  before do
6
7
  mock_conn = double("SolrConnection")
@@ -13,20 +14,20 @@ describe ActiveFedora::Base do
13
14
  end
14
15
 
15
16
  it "makes the solr_document with to_solr and add it" do
16
- expect(subject).to receive(:to_solr)
17
- subject.update_index
17
+ expect(object).to receive(:to_solr)
18
+ object.update_index
18
19
  end
19
20
  end
20
21
 
21
22
  describe ".delete" do
22
23
  before do
23
- allow(subject).to receive(:new_record?).and_return(false)
24
+ allow(object).to receive(:new_record?).and_return(false)
24
25
  allow(ActiveFedora.fedora.connection).to receive(:delete)
25
26
  end
26
27
 
27
28
  it "deletes object from repository and index" do
28
29
  expect(ActiveFedora::SolrService).to receive(:delete).with(nil)
29
- subject.delete
30
+ object.delete
30
31
  end
31
32
  end
32
33
 
@@ -14,17 +14,17 @@ describe ActiveFedora::Base do
14
14
  Object.send(:remove_const, :FooHistory)
15
15
  end
16
16
 
17
- subject { FooHistory.new(title: ["A good title"]) }
18
- before { subject.id = 9 }
17
+ subject(:history) { FooHistory.new(title: ["A good title"]) }
18
+ before { history.id = 9 }
19
19
 
20
20
  it "is settable" do
21
- expect(subject.id).to eq '9'
22
- expect(subject.title).to eq ["A good title"]
21
+ expect(history.id).to eq '9'
22
+ expect(history.title).to eq ["A good title"]
23
23
  end
24
24
 
25
25
  it "is only settable once" do
26
- expect { subject.id = 10 }.to raise_error "ID has already been set to 9"
27
- expect(subject.id).to eq '9'
26
+ expect { history.id = 10 }.to raise_error "ID has already been set to 9"
27
+ expect(history.id).to eq '9'
28
28
  end
29
29
  end
30
30
 
@@ -39,14 +39,14 @@ describe ActiveFedora::Base do
39
39
  Object.send(:remove_const, :FooHistory)
40
40
  end
41
41
 
42
- subject { FooHistory.new.type }
42
+ subject(:history) { FooHistory.new.type }
43
43
 
44
44
  it { is_expected.to eq [RDF::URI('http://example.com/foo')] }
45
45
 
46
46
  context "when type is called before propertes" do
47
- subject { FooHistory.resource_class.reflect_on_property(:title) }
47
+ subject(:history) { FooHistory.resource_class.reflect_on_property(:title) }
48
48
  it "does not wipe out the properties" do
49
- expect(subject).to be_kind_of ActiveTriples::NodeConfig
49
+ expect(history).to be_kind_of ActiveTriples::NodeConfig
50
50
  end
51
51
  end
52
52
  end
@@ -33,26 +33,26 @@ describe ActiveFedora::ChangeSet do
33
33
  let(:base) { Book.create }
34
34
 
35
35
  describe "#changes" do
36
- subject { change_set.changes }
36
+ subject(:changes) { change_set.changes }
37
37
 
38
38
  it { is_expected.to be_kind_of Hash }
39
39
 
40
40
  it "has three elements" do
41
- expect(subject.size).to eq 3
41
+ expect(changes.size).to eq 3
42
42
  end
43
43
  it "does not include URIs from other objects" do
44
44
  base.resource << RDF::Statement.new(RDF::URI("http://wrong.com"), RDF::Vocab::DC.title, "bad")
45
45
  base.title = nil
46
- expect(subject[RDF::Vocab::DC.title].to_a).to eq []
46
+ expect(changes[RDF::Vocab::DC.title].to_a).to eq []
47
47
  end
48
48
  it "includes hash URIs" do
49
49
  # This is useful as an alternative to blank nodes.
50
50
  hash_uri = RDF::URI(base.uri.to_s + "#test")
51
51
  base.resource << RDF::Statement.new(hash_uri, RDF::Vocab::DC.title, "good")
52
52
  base.title = [RDF::URI(hash_uri)]
53
- expect(subject[RDF::Vocab::DC.title].to_a).not_to eq []
53
+ expect(changes[RDF::Vocab::DC.title].to_a).not_to eq []
54
54
  # Include the title reference and the title for the hash URI
55
- expect(subject[RDF::Vocab::DC.title].to_a.length).to eq 2
55
+ expect(changes[RDF::Vocab::DC.title].to_a.length).to eq 2
56
56
  end
57
57
  end
58
58
 
@@ -12,7 +12,7 @@ describe ActiveFedora::Base do
12
12
  end
13
13
 
14
14
  let(:library) { Library.create }
15
- subject { Book.new(library: library, title: "War and Peace", publisher: "Random House") }
15
+ subject(:book) { Book.new(library: library, title: "War and Peace", publisher: "Random House") }
16
16
 
17
17
  after do
18
18
  Object.send(:remove_const, :Book)
@@ -20,61 +20,61 @@ describe ActiveFedora::Base do
20
20
  end
21
21
 
22
22
  it "asserts a content model" do
23
- expect(subject.has_model).to eq ['Book']
23
+ expect(book.has_model).to eq ['Book']
24
24
  end
25
25
 
26
26
  describe "initialize with a block" do
27
- subject { Book.new { |b| b.title = "The Sun also Rises" } }
27
+ subject(:book) { Book.new { |b| b.title = "The Sun also Rises" } }
28
28
 
29
29
  it "has set the title" do
30
- expect(subject.title).to eq "The Sun also Rises"
30
+ expect(book.title).to eq "The Sun also Rises"
31
31
  end
32
32
  end
33
33
 
34
34
  describe "#freeze" do
35
- before { subject.freeze }
35
+ before { book.freeze }
36
36
 
37
37
  it "is frozen" do
38
- expect(subject).to be_frozen
38
+ expect(book).to be_frozen
39
39
  end
40
40
 
41
41
  it "makes the associations immutable" do
42
42
  expect {
43
- subject.library_id = Library.create!.id
43
+ book.library_id = Library.create!.id
44
44
  }.to raise_error RuntimeError, "can't modify frozen Book"
45
- expect(subject.library_id).to eq library.id
45
+ expect(book.library_id).to eq library.id
46
46
  end
47
47
 
48
48
  describe "when the association is set via an id" do
49
- subject { Book.new(library_id: library.id) }
49
+ subject(:book) { Book.new(library_id: library.id) }
50
50
  it "is able to load the association" do
51
- expect(subject.library).to eq library
51
+ expect(book.library).to eq library
52
52
  end
53
53
  end
54
54
 
55
55
  it "makes the properties immutable" do
56
56
  expect {
57
- subject.publisher = "HEY"
57
+ book.publisher = "HEY"
58
58
  }.to raise_error TypeError
59
- expect(subject.publisher).to eq "Random House"
59
+ expect(book.publisher).to eq "Random House"
60
60
  end
61
61
  end
62
62
 
63
63
  describe "an object that hasn't loaded the associations" do
64
- before { subject.save! }
64
+ before { book.save! }
65
65
 
66
66
  it "accesses associations" do
67
- f = Book.find(subject.id)
67
+ f = Book.find(book.id)
68
68
  f.freeze
69
69
  expect(f.library_id).to_not be_nil
70
70
  end
71
71
  end
72
72
 
73
73
  describe "#translate_id_to_uri" do
74
- subject { described_class.translate_id_to_uri }
74
+ subject(:uri) { described_class.translate_id_to_uri }
75
75
  context "when it's not set" do
76
76
  it "is a FedoraIdTranslator" do
77
- expect(subject).to eq ActiveFedora::Core::FedoraIdTranslator
77
+ expect(uri).to eq ActiveFedora::Core::FedoraIdTranslator
78
78
  end
79
79
  end
80
80
  context "when it's set to nil" do
@@ -82,16 +82,16 @@ describe ActiveFedora::Base do
82
82
  described_class.translate_id_to_uri = nil
83
83
  end
84
84
  it "is a FedoraIdTranslator" do
85
- expect(subject).to eq ActiveFedora::Core::FedoraIdTranslator
85
+ expect(uri).to eq ActiveFedora::Core::FedoraIdTranslator
86
86
  end
87
87
  end
88
88
  end
89
89
 
90
90
  describe "#translate_uri_to_id" do
91
- subject { described_class.translate_uri_to_id }
91
+ subject(:uri) { described_class.translate_uri_to_id }
92
92
  context "when it's not set" do
93
93
  it "is a FedoraUriTranslator" do
94
- expect(subject).to eq ActiveFedora::Core::FedoraUriTranslator
94
+ expect(uri).to eq ActiveFedora::Core::FedoraUriTranslator
95
95
  end
96
96
  end
97
97
  context "when it's set to nil" do
@@ -99,14 +99,14 @@ describe ActiveFedora::Base do
99
99
  described_class.translate_uri_to_id = nil
100
100
  end
101
101
  it "is a FedoraIdTranslator" do
102
- expect(subject).to eq ActiveFedora::Core::FedoraUriTranslator
102
+ expect(uri).to eq ActiveFedora::Core::FedoraUriTranslator
103
103
  end
104
104
  end
105
105
  end
106
106
 
107
107
  describe "id_to_uri" do
108
108
  let(:id) { '123456w' }
109
- subject { described_class.id_to_uri(id) }
109
+ subject(:uri) { described_class.id_to_uri(id) }
110
110
 
111
111
  context "with no custom proc is set" do
112
112
  it { should eq "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/123456w" }
@@ -114,7 +114,7 @@ describe ActiveFedora::Base do
114
114
  allow(described_class).to receive(:translate_id_to_uri).and_call_original
115
115
  allow(ActiveFedora::Core::FedoraIdTranslator).to receive(:call).and_call_original
116
116
 
117
- subject
117
+ uri
118
118
 
119
119
  expect(ActiveFedora::Core::FedoraIdTranslator).to have_received(:call).with(id)
120
120
  end
@@ -132,21 +132,21 @@ describe ActiveFedora::Base do
132
132
  context "with an empty base path" do
133
133
  it "produces a valid URI" do
134
134
  allow(ActiveFedora.fedora).to receive(:base_path).and_return("/")
135
- expect(subject).to eq("#{ActiveFedora.fedora.host}/#{id}")
135
+ expect(uri).to eq("#{ActiveFedora.fedora.host}/#{id}")
136
136
  end
137
137
  end
138
138
 
139
139
  context "with a really empty base path" do
140
140
  it "produces a valid URI" do
141
141
  allow(ActiveFedora.fedora).to receive(:base_path).and_return("")
142
- expect(subject).to eq("#{ActiveFedora.fedora.host}/#{id}")
142
+ expect(uri).to eq("#{ActiveFedora.fedora.host}/#{id}")
143
143
  end
144
144
  end
145
145
  end
146
146
 
147
147
  describe "uri_to_id" do
148
148
  let(:uri) { "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/foo/123456w" }
149
- subject { described_class.uri_to_id(uri) }
149
+ subject(:uri_id) { described_class.uri_to_id(uri) }
150
150
 
151
151
  context "with no custom proc is set" do
152
152
  it { should eq 'foo/123456w' }
@@ -154,7 +154,7 @@ describe ActiveFedora::Base do
154
154
  allow(described_class).to receive(:translate_uri_to_id).and_call_original
155
155
  allow(ActiveFedora::Core::FedoraUriTranslator).to receive(:call).and_call_original
156
156
 
157
- subject
157
+ uri_id
158
158
 
159
159
  expect(ActiveFedora::Core::FedoraUriTranslator).to have_received(:call).with(uri)
160
160
  end
@@ -5,7 +5,7 @@ describe ActiveFedora::DefaultModelMapper do
5
5
  let(:classifier_instance) { double }
6
6
  let(:solr_field) { 'solr_field' }
7
7
  let(:predicate) { 'info:predicate' }
8
- subject { described_class.new classifier_class: classifier, solr_field: solr_field, predicate: predicate }
8
+ subject(:mapper) { described_class.new classifier_class: classifier, solr_field: solr_field, predicate: predicate }
9
9
 
10
10
  describe '#classifier' do
11
11
  context 'with a solr document' do
@@ -16,7 +16,7 @@ describe ActiveFedora::DefaultModelMapper do
16
16
  end
17
17
 
18
18
  it 'creates a classifier from the solr field data' do
19
- expect(subject.classifier(solr_document)).to eq classifier_instance
19
+ expect(mapper.classifier(solr_document)).to eq classifier_instance
20
20
  end
21
21
  end
22
22
 
@@ -32,7 +32,7 @@ describe ActiveFedora::DefaultModelMapper do
32
32
  end
33
33
 
34
34
  it 'creates a classifier from the resource model predicate' do
35
- expect(subject.classifier(resource)).to eq classifier_instance
35
+ expect(mapper.classifier(resource)).to eq classifier_instance
36
36
  end
37
37
  end
38
38
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::Fedora do
4
- subject { described_class.new(config) }
4
+ subject(:fedora) { described_class.new(config) }
5
5
  describe "#authorized_connection" do
6
6
  describe "with SSL options" do
7
7
  let(:config) {
@@ -12,7 +12,7 @@ describe ActiveFedora::Fedora do
12
12
  }
13
13
  specify {
14
14
  expect(Faraday).to receive(:new).with("https://example.com", ssl: { ca_path: '/path/to/certs' }).and_call_original
15
- subject.authorized_connection
15
+ fedora.authorized_connection
16
16
  }
17
17
  end
18
18
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'config_helper'
3
3
 
4
4
  describe ActiveFedora::FileConfigurator do
5
- subject { ActiveFedora.configurator }
5
+ subject(:configurator) { ActiveFedora.configurator }
6
6
 
7
7
  after :all do
8
8
  unstub_rails
@@ -19,95 +19,95 @@ describe ActiveFedora::FileConfigurator do
19
19
 
20
20
  describe "#config_options" do
21
21
  before do
22
- subject.reset!
22
+ configurator.reset!
23
23
  end
24
24
  it "is an empty hash" do
25
- expect(subject.config_options).to eq({})
25
+ expect(configurator.config_options).to eq({})
26
26
  end
27
27
  end
28
28
 
29
29
  describe "#fedora_config" do
30
30
  before do
31
- subject.reset!
31
+ configurator.reset!
32
32
  end
33
33
  it "triggers configuration to load" do
34
- expect(subject).to receive(:load_fedora_config)
35
- subject.fedora_config
34
+ expect(configurator).to receive(:load_fedora_config)
35
+ configurator.fedora_config
36
36
  end
37
37
  end
38
38
  describe "#solr_config" do
39
39
  before do
40
- subject.reset!
40
+ configurator.reset!
41
41
  end
42
42
  it "triggers configuration to load" do
43
- expect(subject).to receive(:load_solr_config)
44
- subject.solr_config
43
+ expect(configurator).to receive(:load_solr_config)
44
+ configurator.solr_config
45
45
  end
46
46
  end
47
47
 
48
48
  describe "#reset!" do
49
- before { subject.reset! }
49
+ before { configurator.reset! }
50
50
  it "clears @fedora_config" do
51
- expect(subject.instance_variable_get(:@fedora_config)).to eq({})
51
+ expect(configurator.instance_variable_get(:@fedora_config)).to eq({})
52
52
  end
53
53
  it "clears @solr_config" do
54
- expect(subject.instance_variable_get(:@solr_config)).to eq({})
54
+ expect(configurator.instance_variable_get(:@solr_config)).to eq({})
55
55
  end
56
56
  it "clears @config_options" do
57
- expect(subject.instance_variable_get(:@config_options)).to eq({})
57
+ expect(configurator.instance_variable_get(:@config_options)).to eq({})
58
58
  end
59
59
  end
60
60
 
61
61
  describe "initialization methods" do
62
62
  describe "config_path(:fedora)" do
63
63
  it "uses the config_options[:config_path] if it exists" do
64
- expect(subject).to receive(:config_options).and_return(fedora_config_path: "/path/to/fedora.yml")
64
+ expect(configurator).to receive(:config_options).and_return(fedora_config_path: "/path/to/fedora.yml")
65
65
  expect(File).to receive(:file?).with("/path/to/fedora.yml").and_return(true)
66
- expect(subject.config_path(:fedora)).to eql("/path/to/fedora.yml")
66
+ expect(configurator.config_path(:fedora)).to eql("/path/to/fedora.yml")
67
67
  end
68
68
 
69
69
  it "looks in Rails.root/config/fedora.yml if it exists and no fedora_config_path passed in" do
70
- expect(subject).to receive(:config_options).and_return({})
70
+ expect(configurator).to receive(:config_options).and_return({})
71
71
  stub_rails(root: "/rails/root")
72
72
  expect(File).to receive(:file?).with("/rails/root/config/fedora.yml").and_return(true)
73
- expect(subject.config_path(:fedora)).to eql("/rails/root/config/fedora.yml")
73
+ expect(configurator.config_path(:fedora)).to eql("/rails/root/config/fedora.yml")
74
74
  unstub_rails
75
75
  end
76
76
 
77
77
  it "looks in ./config/fedora.yml if neither rails.root nor :fedora_config_path are set" do
78
- expect(subject).to receive(:config_options).and_return({})
78
+ expect(configurator).to receive(:config_options).and_return({})
79
79
  allow(Dir).to receive(:getwd).and_return("/current/working/directory")
80
80
  expect(File).to receive(:file?).with("/current/working/directory/config/fedora.yml").and_return(true)
81
- expect(subject.config_path(:fedora)).to eql("/current/working/directory/config/fedora.yml")
81
+ expect(configurator.config_path(:fedora)).to eql("/current/working/directory/config/fedora.yml")
82
82
  end
83
83
 
84
84
  it "returns default fedora.yml that ships with active-fedora if none of the above" do
85
- expect(subject).to receive(:config_options).and_return({})
85
+ expect(configurator).to receive(:config_options).and_return({})
86
86
  expect(Dir).to receive(:getwd).and_return("/current/working/directory")
87
87
  expect(File).to receive(:file?).with("/current/working/directory/config/fedora.yml").and_return(false)
88
88
  expect(File).to receive(:file?).with(File.expand_path(File.join(File.dirname("__FILE__"), 'config', 'fedora.yml'))).and_return(true)
89
89
  expect(ActiveFedora::Base.logger).to receive(:warn).with("Using the default fedora.yml that comes with active-fedora. If you want to override this, pass the path to fedora.yml to ActiveFedora - ie. ActiveFedora.init(:fedora_config_path => '/path/to/fedora.yml') - or set Rails.root and put fedora.yml into \#{Rails.root}/config.")
90
- expect(subject.config_path(:fedora)).to eql(File.expand_path(File.join(File.dirname("__FILE__"), 'config', 'fedora.yml')))
90
+ expect(configurator.config_path(:fedora)).to eql(File.expand_path(File.join(File.dirname("__FILE__"), 'config', 'fedora.yml')))
91
91
  end
92
92
  end
93
93
 
94
94
  describe "config_path(:solr)" do
95
95
  it "returns the solr_config_path if set in config_options hash" do
96
- allow(subject).to receive(:config_options).and_return(solr_config_path: "/path/to/solr.yml")
96
+ allow(configurator).to receive(:config_options).and_return(solr_config_path: "/path/to/solr.yml")
97
97
  expect(File).to receive(:file?).with("/path/to/solr.yml").and_return(true)
98
- expect(subject.config_path(:solr)).to eql("/path/to/solr.yml")
98
+ expect(configurator.config_path(:solr)).to eql("/path/to/solr.yml")
99
99
  end
100
100
 
101
101
  it "returns the solr.yml file in the same directory as the fedora.yml if it exists" do
102
- expect(subject).to receive(:path).and_return("/path/to/fedora/config/fedora.yml")
102
+ expect(configurator).to receive(:path).and_return("/path/to/fedora/config/fedora.yml")
103
103
  expect(File).to receive(:file?).with("/path/to/fedora/config/solr.yml").and_return(true)
104
- expect(subject.config_path(:solr)).to eql("/path/to/fedora/config/solr.yml")
104
+ expect(configurator.config_path(:solr)).to eql("/path/to/fedora/config/solr.yml")
105
105
  end
106
106
 
107
107
  context "no solr.yml in same directory as fedora.yml and fedora.yml does not contain solr url" do
108
108
  before :each do
109
- allow(subject).to receive(:config_options).and_return({})
110
- expect(subject).to receive(:path).and_return("/path/to/fedora/config/fedora.yml")
109
+ allow(configurator).to receive(:config_options).and_return({})
110
+ expect(configurator).to receive(:path).and_return("/path/to/fedora/config/fedora.yml")
111
111
  expect(File).to receive(:file?).with("/path/to/fedora/config/solr.yml").and_return(false)
112
112
  end
113
113
  after :each do
@@ -117,13 +117,13 @@ describe ActiveFedora::FileConfigurator do
117
117
  it "does not raise an error if there is not a solr.yml in the same directory as the fedora.yml and the fedora.yml has a solr url defined and look in rails.root" do
118
118
  stub_rails(root: "/rails/root")
119
119
  expect(File).to receive(:file?).with("/rails/root/config/solr.yml").and_return(true)
120
- expect(subject.config_path(:solr)).to eql("/rails/root/config/solr.yml")
120
+ expect(configurator.config_path(:solr)).to eql("/rails/root/config/solr.yml")
121
121
  end
122
122
 
123
123
  it "looks in ./config/solr.yml if no rails root" do
124
124
  allow(Dir).to receive(:getwd).and_return("/current/working/directory")
125
125
  expect(File).to receive(:file?).with("/current/working/directory/config/solr.yml").and_return(true)
126
- expect(subject.config_path(:solr)).to eql("/current/working/directory/config/solr.yml")
126
+ expect(configurator.config_path(:solr)).to eql("/current/working/directory/config/solr.yml")
127
127
  end
128
128
 
129
129
  it "returns the default solr.yml file that ships with active-fedora if no other option is set" do
@@ -131,109 +131,109 @@ describe ActiveFedora::FileConfigurator do
131
131
  expect(File).to receive(:file?).with("/current/working/directory/config/solr.yml").and_return(false)
132
132
  expect(File).to receive(:file?).with(File.expand_path(File.join(File.dirname("__FILE__"), 'config', 'solr.yml'))).and_return(true)
133
133
  expect(ActiveFedora::Base.logger).to receive(:warn).with("Using the default solr.yml that comes with active-fedora. If you want to override this, pass the path to solr.yml to ActiveFedora - ie. ActiveFedora.init(:solr_config_path => '/path/to/solr.yml') - or set Rails.root and put solr.yml into \#{Rails.root}/config.")
134
- expect(subject.config_path(:solr)).to eql(File.expand_path(File.join(File.dirname("__FILE__"), 'config', 'solr.yml')))
134
+ expect(configurator.config_path(:solr)).to eql(File.expand_path(File.join(File.dirname("__FILE__"), 'config', 'solr.yml')))
135
135
  end
136
136
  end
137
137
  end
138
138
 
139
139
  describe "load_fedora_config" do
140
140
  before(:each) do
141
- subject.reset!
141
+ configurator.reset!
142
142
  end
143
143
  it "loads the file specified in fedora_config_path" do
144
- allow(subject).to receive(:load_solrizer_config)
145
- expect(subject).to receive(:config_path).with(:fedora).and_return("/path/to/fedora.yml")
146
- expect(subject).to receive(:load_solr_config)
144
+ allow(configurator).to receive(:load_solrizer_config)
145
+ expect(configurator).to receive(:config_path).with(:fedora).and_return("/path/to/fedora.yml")
146
+ expect(configurator).to receive(:load_solr_config)
147
147
  expect(IO).to receive(:read).with("/path/to/fedora.yml").and_return("development:\n url: http://devfedora:8983\ntest:\n url: http://myfedora:8080")
148
- expect(subject.load_fedora_config).to eq(url: "http://myfedora:8080")
149
- expect(subject.fedora_config).to eq(url: "http://myfedora:8080")
148
+ expect(configurator.load_fedora_config).to eq(url: "http://myfedora:8080")
149
+ expect(configurator.fedora_config).to eq(url: "http://myfedora:8080")
150
150
  end
151
151
 
152
152
  it "allows sharding" do
153
- allow(subject).to receive(:load_solrizer_config)
154
- expect(subject).to receive(:config_path).with(:fedora).and_return("/path/to/fedora.yml")
155
- expect(subject).to receive(:load_solr_config)
153
+ allow(configurator).to receive(:load_solrizer_config)
154
+ expect(configurator).to receive(:config_path).with(:fedora).and_return("/path/to/fedora.yml")
155
+ expect(configurator).to receive(:load_solr_config)
156
156
  expect(IO).to receive(:read).with("/path/to/fedora.yml").and_return("development:\n url: http://devfedora:8983\ntest:\n- url: http://myfedora:8080\n- url: http://myfedora:8081")
157
- expect(subject.load_fedora_config).to eq [{ url: "http://myfedora:8080" }, { url: "http://myfedora:8081" }]
158
- expect(subject.fedora_config).to eq [{ url: "http://myfedora:8080" }, { url: "http://myfedora:8081" }]
157
+ expect(configurator.load_fedora_config).to eq [{ url: "http://myfedora:8080" }, { url: "http://myfedora:8081" }]
158
+ expect(configurator.fedora_config).to eq [{ url: "http://myfedora:8080" }, { url: "http://myfedora:8081" }]
159
159
  end
160
160
 
161
161
  it "parses the file using ERb" do
162
- allow(subject).to receive(:load_solrizer_config)
163
- expect(subject).to receive(:config_path).with(:fedora).and_return("/path/to/fedora.yml")
164
- expect(subject).to receive(:load_solr_config)
162
+ allow(configurator).to receive(:load_solrizer_config)
163
+ expect(configurator).to receive(:config_path).with(:fedora).and_return("/path/to/fedora.yml")
164
+ expect(configurator).to receive(:load_solr_config)
165
165
  expect(IO).to receive(:read).with("/path/to/fedora.yml").and_return("development:\n url: http://devfedora:<%= 8983 %>\ntest:\n url: http://myfedora:<%= 8081 %>")
166
- expect(subject.load_fedora_config).to eq(url: "http://myfedora:8081")
167
- expect(subject.fedora_config).to eq(url: "http://myfedora:8081")
166
+ expect(configurator.load_fedora_config).to eq(url: "http://myfedora:8081")
167
+ expect(configurator.fedora_config).to eq(url: "http://myfedora:8081")
168
168
  end
169
169
  end
170
170
 
171
171
  describe "load_solr_config" do
172
172
  before(:each) do
173
- subject.reset!
173
+ configurator.reset!
174
174
  end
175
175
  it "loads the file specified in solr_config_path" do
176
- allow(subject).to receive(:load_solrizer_config)
177
- expect(subject).to receive(:config_path).with(:solr).and_return("/path/to/solr.yml")
178
- expect(subject).to receive(:load_fedora_config)
176
+ allow(configurator).to receive(:load_solrizer_config)
177
+ expect(configurator).to receive(:config_path).with(:solr).and_return("/path/to/solr.yml")
178
+ expect(configurator).to receive(:load_fedora_config)
179
179
  expect(IO).to receive(:read).with("/path/to/solr.yml").and_return("development:\n default:\n url: http://devsolr:8983\ntest:\n default:\n url: http://mysolr:8080")
180
- expect(subject.load_solr_config).to eq(url: "http://mysolr:8080")
181
- expect(subject.solr_config).to eq(url: "http://mysolr:8080")
180
+ expect(configurator.load_solr_config).to eq(url: "http://mysolr:8080")
181
+ expect(configurator.solr_config).to eq(url: "http://mysolr:8080")
182
182
  end
183
183
 
184
184
  it "parses the file using ERb" do
185
- allow(subject).to receive(:load_solrizer_config)
186
- expect(subject).to receive(:config_path).with(:solr).and_return("/path/to/solr.yml")
187
- expect(subject).to receive(:load_fedora_config)
185
+ allow(configurator).to receive(:load_solrizer_config)
186
+ expect(configurator).to receive(:config_path).with(:solr).and_return("/path/to/solr.yml")
187
+ expect(configurator).to receive(:load_fedora_config)
188
188
  expect(IO).to receive(:read).with("/path/to/solr.yml").and_return("development:\n default:\n url: http://devsolr:<%= 8983 %>\ntest:\n default:\n url: http://mysolr:<%= 8081 %>")
189
- expect(subject.load_solr_config).to eq(url: "http://mysolr:8081")
190
- expect(subject.solr_config).to eq(url: "http://mysolr:8081")
189
+ expect(configurator.load_solr_config).to eq(url: "http://mysolr:8081")
190
+ expect(configurator.solr_config).to eq(url: "http://mysolr:8081")
191
191
  end
192
192
 
193
193
  it "includes update_path and select_path in solr_config" do
194
- allow(subject).to receive(:load_solrizer_config)
195
- expect(subject).to receive(:config_path).with(:solr).and_return("/path/to/solr.yml")
196
- expect(subject).to receive(:load_fedora_config)
194
+ allow(configurator).to receive(:load_solrizer_config)
195
+ expect(configurator).to receive(:config_path).with(:solr).and_return("/path/to/solr.yml")
196
+ expect(configurator).to receive(:load_fedora_config)
197
197
  expect(IO).to receive(:read).with("/path/to/solr.yml").and_return("test:\n url: http://mysolr:8080\n update_path: update_test\n select_path: select_test\n")
198
- expect(subject.solr_config[:update_path]).to eq('update_test')
199
- expect(subject.solr_config[:select_path]).to eq('select_test')
198
+ expect(configurator.solr_config[:update_path]).to eq('update_test')
199
+ expect(configurator.solr_config[:select_path]).to eq('select_test')
200
200
  end
201
201
  end
202
202
 
203
203
  describe "load_configs" do
204
204
  describe "when config is not loaded" do
205
205
  before do
206
- subject.instance_variable_set :@config_loaded, nil
206
+ configurator.instance_variable_set :@config_loaded, nil
207
207
  end
208
208
  it "loads the fedora and solr configs" do
209
- expect(subject).to_not be_config_loaded
210
- subject.load_configs
211
- expect(subject).to be_config_loaded
209
+ expect(configurator).to_not be_config_loaded
210
+ configurator.load_configs
211
+ expect(configurator).to be_config_loaded
212
212
  end
213
213
  end
214
214
  describe "when config is loaded" do
215
215
  before do
216
- subject.instance_variable_set :@config_loaded, true
216
+ configurator.instance_variable_set :@config_loaded, true
217
217
  end
218
218
  it "loads the fedora and solr configs" do
219
- expect(subject).to receive(:load_config).never
220
- expect(subject).to be_config_loaded
221
- subject.load_configs
222
- expect(subject).to be_config_loaded
219
+ expect(configurator).to receive(:load_config).never
220
+ expect(configurator).to be_config_loaded
221
+ configurator.load_configs
222
+ expect(configurator).to be_config_loaded
223
223
  end
224
224
  end
225
225
  end
226
226
 
227
227
  describe "check_fedora_path_for_solr" do
228
228
  it "finds the solr.yml file and return it if it exists" do
229
- expect(subject).to receive(:path).and_return("/path/to/fedora/fedora.yml")
229
+ expect(configurator).to receive(:path).and_return("/path/to/fedora/fedora.yml")
230
230
  expect(File).to receive(:file?).with("/path/to/fedora/solr.yml").and_return(true)
231
- expect(subject.check_fedora_path_for_solr).to eq "/path/to/fedora/solr.yml"
231
+ expect(configurator.check_fedora_path_for_solr).to eq "/path/to/fedora/solr.yml"
232
232
  end
233
233
  it "returns nil if the solr.yml file is not there" do
234
- expect(subject).to receive(:path).and_return("/path/to/fedora/fedora.yml")
234
+ expect(configurator).to receive(:path).and_return("/path/to/fedora/fedora.yml")
235
235
  expect(File).to receive(:file?).with("/path/to/fedora/solr.yml").and_return(false)
236
- expect(subject.check_fedora_path_for_solr).to be_nil
236
+ expect(configurator.check_fedora_path_for_solr).to be_nil
237
237
  end
238
238
  end
239
239
  end
@@ -250,32 +250,32 @@ describe ActiveFedora::FileConfigurator do
250
250
  end
251
251
 
252
252
  it "can tell its config paths" do
253
- subject.init
254
- expect(subject).to respond_to(:solr_config_path)
253
+ configurator.init
254
+ expect(configurator).to respond_to(:solr_config_path)
255
255
  end
256
256
 
257
257
  it "loads a config from the current working directory as a second choice" do
258
- allow(subject).to receive(:load_solrizer_config)
258
+ allow(configurator).to receive(:load_solrizer_config)
259
259
  allow(Dir).to receive(:getwd).and_return(@fake_rails_root)
260
- subject.init
261
- expect(subject.config_path(:fedora)).to eql("#{@fake_rails_root}/config/fedora.yml")
262
- expect(subject.solr_config_path).to eql("#{@fake_rails_root}/config/solr.yml")
260
+ configurator.init
261
+ expect(configurator.config_path(:fedora)).to eql("#{@fake_rails_root}/config/fedora.yml")
262
+ expect(configurator.solr_config_path).to eql("#{@fake_rails_root}/config/solr.yml")
263
263
  end
264
264
 
265
265
  it "loads the config that ships with this gem as a last choice" do
266
266
  allow(Dir).to receive(:getwd).and_return("/fake/path")
267
- allow(subject).to receive(:load_solrizer_config)
267
+ allow(configurator).to receive(:load_solrizer_config)
268
268
  expect(ActiveFedora::Base.logger).to receive(:warn).with("Using the default fedora.yml that comes with active-fedora. If you want to override this, pass the path to fedora.yml to ActiveFedora - ie. ActiveFedora.init(:fedora_config_path => '/path/to/fedora.yml') - or set Rails.root and put fedora.yml into \#{Rails.root}/config.").exactly(3).times
269
- subject.init
269
+ configurator.init
270
270
  expected_config = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "config"))
271
- expect(subject.config_path(:fedora)).to eql(expected_config + '/fedora.yml')
272
- expect(subject.solr_config_path).to eql(expected_config + '/solr.yml')
271
+ expect(configurator.config_path(:fedora)).to eql(expected_config + '/fedora.yml')
272
+ expect(configurator.solr_config_path).to eql(expected_config + '/solr.yml')
273
273
  end
274
274
  it "raises an error if you pass in a string" do
275
- expect(lambda { subject.init("#{@fake_rails_root}/config/fake_fedora.yml") }).to raise_exception(ArgumentError)
275
+ expect(lambda { configurator.init("#{@fake_rails_root}/config/fake_fedora.yml") }).to raise_exception(ArgumentError)
276
276
  end
277
277
  it "raises an error if you pass in a non-existant config file" do
278
- expect(lambda { subject.init(fedora_config_path: "really_fake_fedora.yml") }).to raise_exception(ActiveFedora::ConfigurationError)
278
+ expect(lambda { configurator.init(fedora_config_path: "really_fake_fedora.yml") }).to raise_exception(ActiveFedora::ConfigurationError)
279
279
  end
280
280
 
281
281
  describe "within Rails" do
@@ -288,15 +288,15 @@ describe ActiveFedora::FileConfigurator do
288
288
  end
289
289
 
290
290
  it "loads a config from Rails.root as a first choice" do
291
- allow(subject).to receive(:load_solrizer_config)
292
- subject.init
293
- expect(subject.config_path(:fedora)).to eql("#{Rails.root}/config/fedora.yml")
294
- expect(subject.solr_config_path).to eql("#{Rails.root}/config/solr.yml")
291
+ allow(configurator).to receive(:load_solrizer_config)
292
+ configurator.init
293
+ expect(configurator.config_path(:fedora)).to eql("#{Rails.root}/config/fedora.yml")
294
+ expect(configurator.solr_config_path).to eql("#{Rails.root}/config/solr.yml")
295
295
  end
296
296
 
297
297
  it "can tell what environment it is set to run in" do
298
298
  stub_rails(env: "development")
299
- subject.init
299
+ configurator.init
300
300
  expect(ActiveFedora.environment).to eql("development")
301
301
  end
302
302
  end