active_fedora-noid 2.0.0.beta6 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e04703fc928d905a2fdabb0bdf8c967e1b4fef9f
4
- data.tar.gz: 0d40c8fb02c9542e9437650dc4fa412f9e123682
3
+ metadata.gz: b7053ed97886ba613915252ff2a773d3355577aa
4
+ data.tar.gz: b5c5d8f381ee2d0c78d1ee5d3fa4c97e281d91d6
5
5
  SHA512:
6
- metadata.gz: b6263908c04be9f4e91ae44e21451b3bfd6a32cde46d5e6b612887cd278df4e5b5e15f1852a6bd04e226430eadaca546e18749b536141d223f8f9f0f8e3679d8
7
- data.tar.gz: cbf2b293055b1505e4f8c45038ae1764b1cef69c2423cdbbfcfdded6608b854bed38a2ee8a3f1a14545e911de33e3558baff788d6c8cdf67f74448de2c9089b3
6
+ metadata.gz: 06e120b319deeb12f6d92de5c5d9d9bb1c8765fcf23c7bcdcfe2310685b83869193c8995aa808bf10191f68ba2854c0e3ca574935a9694b92cba4559ee0ed1bb
7
+ data.tar.gz: 777c190afa32118fc4f0ab931aec01b9df8309c0fd29ffaafd8d71ff8e13bf31c3b99b390c72685b82d3f67cf117386537ac7633d7a17ea19ebe0837b7435d00
@@ -21,7 +21,7 @@ RSpec/ExampleLength:
21
21
  - 'spec/unit/db_minter_spec.rb'
22
22
  - 'spec/unit/file_minter_spec.rb'
23
23
 
24
- # Offense count: 5
24
+ # Offense count: 6
25
25
  # Configuration parameters: CustomTransform.
26
26
  RSpec/FilePath:
27
27
  Exclude:
@@ -30,6 +30,7 @@ RSpec/FilePath:
30
30
  - 'spec/unit/file_minter_spec.rb'
31
31
  - 'spec/unit/noid_spec.rb'
32
32
  - 'spec/unit/service_spec.rb'
33
+ - 'spec/unit/rspec_spec.rb'
33
34
 
34
35
  # Offense count: 9
35
36
  RSpec/LeadingSubject:
@@ -37,6 +38,11 @@ RSpec/LeadingSubject:
37
38
  - 'spec/unit/config_spec.rb'
38
39
  - 'spec/unit/file_minter_spec.rb'
39
40
 
41
+ # Offense count: 3
42
+ RSpec/InstanceVariable:
43
+ Exclude:
44
+ - 'spec/unit/rspec_spec.rb'
45
+
40
46
  # Offense count: 4
41
47
  RSpec/MessageChain:
42
48
  Exclude:
@@ -64,12 +70,13 @@ RSpec/NamedSubject:
64
70
  - 'spec/unit/noid_spec.rb'
65
71
  - 'spec/unit/service_spec.rb'
66
72
 
67
- # Offense count: 11
73
+ # Offense count: 12
68
74
  # Configuration parameters: MaxNesting.
69
75
  RSpec/NestedGroups:
70
76
  Exclude:
71
77
  - 'spec/unit/config_spec.rb'
72
78
  - 'spec/unit/noid_spec.rb'
79
+ - 'spec/unit/rspec_spec.rb'
73
80
 
74
81
  # Offense count: 3
75
82
  # Configuration parameters: IgnoreSymbolicNames.
@@ -9,9 +9,3 @@ env:
9
9
  matrix:
10
10
  - "RAILS_VERSION=4.2.7.1"
11
11
  - "RAILS_VERSION=5.0.0.1"
12
- notifications:
13
- irc:
14
- channels:
15
- - "irc.freenode.org#projecthydra"
16
- template:
17
- - "%{repository}//%{branch}@%{commit} by %{author}: %{message} - %{build_url}"
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  Code: [![Version](https://badge.fury.io/rb/active_fedora-noid.png)](http://badge.fury.io/rb/active_fedora-noid)
2
- [![Build Status](https://travis-ci.org/projecthydra-labs/active_fedora-noid.png?branch=master)](https://travis-ci.org/projecthydra-labs/active_fedora-noid)
3
- [![Coverage Status](https://coveralls.io/repos/github/projecthydra-labs/active_fedora-noid/badge.svg?branch=master)](https://coveralls.io/github/projecthydra-labs/active_fedora-noid?branch=master)
4
- [![Code Climate](https://codeclimate.com/github/projecthydra-labs/active_fedora-noid/badges/gpa.svg)](https://codeclimate.com/github/projecthydra-labs/active_fedora-noid)
5
- [![Dependency Status](https://gemnasium.com/projecthydra-labs/active_fedora-noid.png)](https://gemnasium.com/projecthydra-labs/active_fedora-noid)
2
+ [![Build Status](https://travis-ci.org/projecthydra/active_fedora-noid.png?branch=master)](https://travis-ci.org/projecthydra/active_fedora-noid)
3
+ [![Coverage Status](https://coveralls.io/repos/github/projecthydra/active_fedora-noid/badge.svg?branch=master)](https://coveralls.io/github/projecthydra/active_fedora-noid?branch=master)
4
+ [![Code Climate](https://codeclimate.com/github/projecthydra/active_fedora-noid/badges/gpa.svg)](https://codeclimate.com/github/projecthydra/active_fedora-noid)
5
+ [![Dependency Status](https://gemnasium.com/projecthydra/active_fedora-noid.png)](https://gemnasium.com/projecthydra/active_fedora-noid)
6
6
 
7
- Docs: [![Documentation Status](https://inch-ci.org/github/projecthydra-labs/active_fedora-noid.svg?branch=master)](https://inch-ci.org/github/projecthydra-labs/active_fedora-noid)
7
+ Docs: [![Documentation Status](https://inch-ci.org/github/projecthydra/active_fedora-noid.svg?branch=master)](https://inch-ci.org/github/projecthydra/active_fedora-noid)
8
8
  [![API Docs](http://img.shields.io/badge/API-docs-blue.svg)](http://rubydoc.info/gems/active_fedora-noid)
9
9
  [![Contribution Guidelines](http://img.shields.io/badge/CONTRIBUTING-Guidelines-blue.svg)](./CONTRIBUTING.md)
10
10
  [![Apache 2.0 License](http://img.shields.io/badge/APACHE2-license-blue.svg)](./LICENSE)
@@ -99,7 +99,7 @@ This will make sure your objects have Noid-like identifiers (e.g. `bb22bb22b`) t
99
99
 
100
100
  ## Overriding default behavior
101
101
 
102
- The default minter in ActiveFedora::Noid 2.x is the file-backed minter to preserve default behavior.
102
+ The default minter in ActiveFedora::Noid 2.0.0 is the file-backed minter to preserve default behavior.
103
103
 
104
104
  To better support multi-host production installations that expect a shared database but not necessarily a shared filesystem (e.g., between load-balanced Rails applications), we highly recommend swapping in the database-backed minter.
105
105
 
@@ -132,8 +132,15 @@ $ rake active_fedora:noid:migrate:database_to_file
132
132
 
133
133
  **NOTE 2**: If you decide to use the database-backed minter, you may notice that your test suite now fails miserably if it is configured to clear out the application database between tests. If so, you may add the following to e.g. `spec/spec_helper.rb` to set the default minter in the test suite as the file-backed one:
134
134
 
135
- ``` ruby
135
+ ```ruby
136
136
  require 'active_fedora/noid/rspec'
137
+
138
+ RSpec.configure do |config|
139
+ config.include(ActiveFedora::Noid::RSpec)
140
+ end
141
+
142
+ before(:suite) { disable_production_minter! }
143
+ after(:suite) { enable_production_minter! }
137
144
  ```
138
145
 
139
146
  ### Identifier template
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ['leftwing@alumni.rutgers.edu']
12
12
  spec.summary = 'Noid identifier services for ActiveFedora-based applications'
13
13
  spec.description = 'Noid identifier services for ActiveFedora-based applications.'
14
- spec.homepage = 'https://github.com/projecthydra-labs/active_fedora-noid'
14
+ spec.homepage = 'https://github.com/projecthydra/active_fedora-noid'
15
15
  spec.license = 'Apache2'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0")
@@ -1,8 +1,66 @@
1
1
  # frozen_string_literal: true
2
- RSpec.configure do |config|
3
- config.before(:suite) do
4
- ActiveFedora::Noid.configure do |noid_config|
5
- noid_config.minter_class = ActiveFedora::Noid::Minter::File
2
+ module ActiveFedora
3
+ module Noid
4
+ ##
5
+ # Provides a test minter conforming to the `ActiveFedora::Noid::Minter`
6
+ # interface for use in unit tests. The test minter is faster and avoids
7
+ # unexpected interactions with cleanup code commonly runs in test suites
8
+ # (e.g. database cleanup).
9
+ #
10
+ # Applications should reenable their production minter for integration tests
11
+ # when appropriate
12
+ #
13
+ # @example general use
14
+ # ActiveFedora::Noid::RSpec.disable_production_minter!
15
+ # # some unit tests with the test minter
16
+ # ActiveFedora::Noid::RSpec.enable_production_minter!
17
+ # # some integration tests with the original minter
18
+ #
19
+ # @example using a custom test minter
20
+ # ActiveFedora::Noid::RSpec.disable_production_minter!(test_minter: Minter)
21
+ #
22
+ # @example use when included in RSpec config
23
+ # require 'active_fedora/noid/rspec'
24
+ #
25
+ # RSpec.configure do |config|
26
+ # config.include(ActiveFedora::Noid::RSpec)
27
+ # end
28
+ #
29
+ # before(:suite) { disable_production_minter! }
30
+ # after(:suite) { enable_production_minter! }
31
+ #
32
+ module RSpec
33
+ DEFAULT_TEST_MINTER = ActiveFedora::Noid::Minter::File
34
+
35
+ ##
36
+ # Replaces the configured production minter with a test minter.
37
+ #
38
+ # @param test_minter [Class] an ActiveFedora::Noid::Minter implementation
39
+ # to use as a replacement minter
40
+ # @return [void]
41
+ def disable_production_minter!(test_minter: DEFAULT_TEST_MINTER)
42
+ return nil if @original_minter
43
+
44
+ @original_minter = ActiveFedora::Noid.config.minter_class
45
+
46
+ ActiveFedora::Noid.configure do |noid_config|
47
+ noid_config.minter_class = test_minter
48
+ end
49
+ end
50
+
51
+ ##
52
+ # Re-enables the original configured minter.
53
+ #
54
+ # @return [void]
55
+ def enable_production_minter!
56
+ return nil unless @original_minter
57
+
58
+ ActiveFedora::Noid.configure do |noid_config|
59
+ noid_config.minter_class = @original_minter
60
+ end
61
+
62
+ @original_minter = nil
63
+ end
6
64
  end
7
65
  end
8
66
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module ActiveFedora
3
3
  module Noid
4
- VERSION = '2.0.0.beta6'
4
+ VERSION = '2.0.0'
5
5
  end
6
6
  end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+ require 'active_fedora/noid/rspec'
3
+
4
+ describe ActiveFedora::Noid::RSpec do
5
+ include described_class
6
+
7
+ let(:configured_minter) { @configured_minter }
8
+ let(:var_name) { :@original_minter }
9
+
10
+ before do
11
+ @configured_minter = Class.new(ActiveFedora::Noid::Minter::Base)
12
+ @reset_minter = ActiveFedora::Noid.config.minter_class
13
+
14
+ ActiveFedora::Noid.configure do |noid_config|
15
+ noid_config.minter_class = @configured_minter
16
+ end
17
+ end
18
+
19
+ after do
20
+ ActiveFedora::Noid.configure do |noid_config|
21
+ noid_config.minter_class = @reset_minter
22
+ end
23
+ end
24
+
25
+ describe '#disable_production_minter!' do
26
+ it 'changes the configured minter' do
27
+ expect { disable_production_minter! }
28
+ .to change { ActiveFedora::Noid.config.minter_class }
29
+ .from(configured_minter)
30
+ .to described_class::DEFAULT_TEST_MINTER
31
+ end
32
+
33
+ it 'accepts custom test minter at call time' do
34
+ my_minter = Class.new(ActiveFedora::Noid::Minter::Base)
35
+
36
+ expect { disable_production_minter!(test_minter: my_minter) }
37
+ .to change { ActiveFedora::Noid.config.minter_class }
38
+ .from(configured_minter)
39
+ .to my_minter
40
+ end
41
+
42
+ it 'does not overwrite stored minter on second call' do
43
+ disable_production_minter!
44
+
45
+ expect { disable_production_minter! }
46
+ .not_to change { described_class.instance_variable_get(var_name) }
47
+ end
48
+
49
+ it 'still reenables after second call' do
50
+ 2.times { disable_production_minter! }
51
+ expect { enable_production_minter! }
52
+ .to change { ActiveFedora::Noid.config.minter_class }
53
+ .from(described_class::DEFAULT_TEST_MINTER).to configured_minter
54
+ end
55
+
56
+ it 'disables after reenable' do
57
+ disable_production_minter!
58
+ enable_production_minter!
59
+ expect { disable_production_minter! }
60
+ .to change { ActiveFedora::Noid.config.minter_class }
61
+ .from(configured_minter).to described_class::DEFAULT_TEST_MINTER
62
+ end
63
+ end
64
+
65
+ describe '#enable_production_minter!' do
66
+ it 'does nothing when already enabled' do
67
+ expect { enable_production_minter! }
68
+ .not_to change { ActiveFedora::Noid.config.minter_class }
69
+ end
70
+
71
+ context 'with minter disabled' do
72
+ before { disable_production_minter! }
73
+
74
+ it 'reenables the originally configured minter' do
75
+ expect { enable_production_minter! }
76
+ .to change { ActiveFedora::Noid.config.minter_class }
77
+ .from(described_class::DEFAULT_TEST_MINTER)
78
+ .to configured_minter
79
+ end
80
+
81
+ it 'enables after re-disable' do
82
+ enable_production_minter!
83
+ disable_production_minter!
84
+ expect { enable_production_minter! }
85
+ .to change { ActiveFedora::Noid.config.minter_class }
86
+ .from(described_class::DEFAULT_TEST_MINTER).to configured_minter
87
+ end
88
+ end
89
+ end
90
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_fedora-noid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta6
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael J. Giarlo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-26 00:00:00.000000000 Z
11
+ date: 2016-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active-fedora
@@ -205,8 +205,9 @@ files:
205
205
  - spec/unit/db_minter_spec.rb
206
206
  - spec/unit/file_minter_spec.rb
207
207
  - spec/unit/noid_spec.rb
208
+ - spec/unit/rspec_spec.rb
208
209
  - spec/unit/service_spec.rb
209
- homepage: https://github.com/projecthydra-labs/active_fedora-noid
210
+ homepage: https://github.com/projecthydra/active_fedora-noid
210
211
  licenses:
211
212
  - Apache2
212
213
  metadata: {}
@@ -221,9 +222,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
221
222
  version: '0'
222
223
  required_rubygems_version: !ruby/object:Gem::Requirement
223
224
  requirements:
224
- - - ">"
225
+ - - ">="
225
226
  - !ruby/object:Gem::Version
226
- version: 1.3.1
227
+ version: '0'
227
228
  requirements: []
228
229
  rubyforge_project:
229
230
  rubygems_version: 2.5.1
@@ -240,4 +241,5 @@ test_files:
240
241
  - spec/unit/db_minter_spec.rb
241
242
  - spec/unit/file_minter_spec.rb
242
243
  - spec/unit/noid_spec.rb
244
+ - spec/unit/rspec_spec.rb
243
245
  - spec/unit/service_spec.rb