uncruft 0.0.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -7
- data/Rakefile +10 -8
- data/lib/uncruft/deprecatable.rb +25 -0
- data/lib/uncruft/deprecation_handler.rb +8 -10
- data/lib/uncruft/version.rb +1 -1
- data/lib/uncruft/warning.rb +4 -2
- data/lib/uncruft.rb +7 -3
- data/spec/spec_helper.rb +6 -2
- data/spec/uncruft/deprecatable_spec.rb +58 -0
- data/spec/uncruft/deprecation_handler_spec.rb +18 -18
- data/spec/uncruft/warning_spec.rb +3 -3
- data/spec/uncruft_spec.rb +24 -24
- metadata +20 -20
- data/spec/dummy/config/deprecations.ignore +0 -7
- data/spec/examples.txt +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c93c7cc504ba0e5d3bf93b8ffbbfadee05e66c8084f3580fc93855490ed4ec3
|
4
|
+
data.tar.gz: 6b1f3835bb69a640c757896730bb9cf284f212087f9f04339709e0186f921b92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6427a8d529e5b0f51f26c3fc8b88f06d3f9823a0d02eb0e3cfdf3c00419dab9c9f2c634adec618ba21c72f54cc9ddedd6b90c18aaad854ea7c0564c224dff52
|
7
|
+
data.tar.gz: 67fba4c3a6ba79098cc141f597e7965917804306b41d5299cb4795600f191a3c5c8589506e4073d7be9ec6f045b75abe635338a75077ebc28b35b4848773d446
|
data/README.md
CHANGED
@@ -21,23 +21,46 @@ Then run `bundle install`.
|
|
21
21
|
|
22
22
|
By default, deprecation warnings will cause your application to raise exceptions in `test` and `development` modes.
|
23
23
|
|
24
|
-
The exception message will include the original deprecation warning, plus a link to [our troubleshooting guide](https://github.com/Betterment/uncruft/blob/
|
24
|
+
The exception message will include the original deprecation warning, plus a link to [our troubleshooting guide](https://github.com/Betterment/uncruft/blob/main/GUIDE.md), to assist with resolving deprecations as they are encountered.
|
25
25
|
|
26
|
-
##
|
26
|
+
## Recording Deprecations
|
27
27
|
|
28
|
-
When testing on a new Rails version for the first time, you will undoubtedly encounter many new warnings. As such, you can quickly
|
28
|
+
When testing on a new Rails version for the first time, you will undoubtedly encounter many new warnings. As such, you can quickly record all existing deprecation warnings encountered during your test suite like so:
|
29
29
|
|
30
30
|
```bash
|
31
|
-
|
31
|
+
RECORD_DEPRECATIONS=1 rake
|
32
32
|
```
|
33
33
|
|
34
|
-
|
34
|
+
This will generate (or add to) an ignorefile of warnings at `config/deprecations.ignore`. Any warning in that file will be ignored when next encountered.
|
35
|
+
|
36
|
+
You can also incrementally add new warnings to the ignorefile as you encounter them:
|
35
37
|
|
36
38
|
```bash
|
37
|
-
|
39
|
+
RECORD_DEPRECATIONS=1 rspec path/to/my/failing/spec.rb
|
38
40
|
```
|
39
41
|
|
40
|
-
|
42
|
+
## Deprecating Attributes and Methods
|
43
|
+
|
44
|
+
If you would like to deprecate an attribute by applying a `ActiveSupport::Deprecation` warning on the deprecated attribute's getters and setters then look no further, we have a tool for that! Simply include `Uncruft::Deprecatable` in your class, identify the attribute you would like deprecated and provide a message you would like applied to the deprecation warning.
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
class Customer
|
48
|
+
include Uncruft::Deprecatable
|
49
|
+
|
50
|
+
attr_accessor :first_name
|
51
|
+
|
52
|
+
def initialize(first_name)
|
53
|
+
@first_name = first_name
|
54
|
+
end
|
55
|
+
|
56
|
+
deprecate_attribute(:first_name,
|
57
|
+
message: "Please stop using first_name it is deprecated, please use legal_first_name instead!")
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
61
|
+
Within the `Uncruft::Deprecatable` module there is also a `.deprecate_method` method that can be used to apply a deprecation warning to an identified method, much like the `deprecate_attribute` method described above.
|
62
|
+
|
63
|
+
From there you can use Uncruft's deprecation recording tools to generate ingorefiles and manage your deprecation backlog in an organized manner.
|
41
64
|
|
42
65
|
## How to Contribute
|
43
66
|
|
data/Rakefile
CHANGED
@@ -6,8 +6,6 @@ end
|
|
6
6
|
|
7
7
|
Bundler::GemHelper.install_tasks
|
8
8
|
|
9
|
-
task(:default).clear
|
10
|
-
|
11
9
|
require 'rubocop/rake_task'
|
12
10
|
RuboCop::RakeTask.new
|
13
11
|
|
@@ -15,10 +13,14 @@ require 'rspec/core'
|
|
15
13
|
require 'rspec/core/rake_task'
|
16
14
|
RSpec::Core::RakeTask.new(:spec)
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
def default_task
|
17
|
+
if ENV['APPRAISAL_INITIALIZED'] || ENV['CI']
|
18
|
+
%i(rubocop spec)
|
19
|
+
else
|
20
|
+
require 'appraisal'
|
21
|
+
Appraisal::Task.new
|
22
|
+
%i(appraisal)
|
23
|
+
end
|
24
24
|
end
|
25
|
+
|
26
|
+
task(:default).clear.enhance(default_task)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Uncruft
|
2
|
+
module Deprecatable
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def deprecate_attribute(attribute, message:)
|
7
|
+
deprecate_method attribute, message: message
|
8
|
+
deprecate_method :"#{attribute}=", message: message
|
9
|
+
end
|
10
|
+
|
11
|
+
def deprecate_method(method, message:)
|
12
|
+
prepended_method = Module.new
|
13
|
+
|
14
|
+
prepended_method.module_eval do
|
15
|
+
define_method method do |*args, &block|
|
16
|
+
ActiveSupport::Deprecation.warn(message)
|
17
|
+
super(*args, &block)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
prepend prepended_method
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -15,7 +15,7 @@ module Uncruft
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def handle_unknown_deprecation!(message, line_number)
|
18
|
-
if Uncruft.
|
18
|
+
if Uncruft.record_deprecations?
|
19
19
|
known_deprecations << message
|
20
20
|
write_deprecations_file!
|
21
21
|
else
|
@@ -86,7 +86,7 @@ module Uncruft
|
|
86
86
|
To resolve this error, adjust your code according to the instructions above.
|
87
87
|
If you did not introduce this error or are unsure why you are seeing it,
|
88
88
|
you will find additional guidance at the URL below:
|
89
|
-
https://github.com/Betterment/uncruft/blob/
|
89
|
+
https://github.com/Betterment/uncruft/blob/main/GUIDE.md
|
90
90
|
ERROR
|
91
91
|
end
|
92
92
|
|
@@ -95,14 +95,12 @@ module Uncruft
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def known_deprecations
|
98
|
-
@known_deprecations ||=
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
end
|
105
|
-
end
|
98
|
+
@known_deprecations ||= if known_deprecations_file_exists?
|
99
|
+
file = File.read(Uncruft.ignorefile_path)
|
100
|
+
JSON.parse(file)['ignored_warnings'].to_set
|
101
|
+
else
|
102
|
+
Set.new
|
103
|
+
end
|
106
104
|
end
|
107
105
|
|
108
106
|
def file_content(deprecations)
|
data/lib/uncruft/version.rb
CHANGED
data/lib/uncruft/warning.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
module Uncruft
|
2
2
|
module Warning
|
3
|
-
DEPRECATION_PATTERN = /(deprecation|deprecated)/i
|
3
|
+
DEPRECATION_PATTERN = /(deprecation|deprecated)/i.freeze
|
4
4
|
|
5
|
-
def warn(str, *args)
|
5
|
+
def warn(str, *args, **kwargs)
|
6
6
|
if str =~ DEPRECATION_PATTERN # rubocop:disable Performance/RegexpMatch
|
7
7
|
message = strip_caller_info(str, caller_locations(1..1).first).strip
|
8
8
|
ActiveSupport::Deprecation.warn(message)
|
9
|
+
elsif RUBY_VERSION < '2.7' && kwargs.empty?
|
10
|
+
super(str, *args)
|
9
11
|
else
|
10
12
|
super
|
11
13
|
end
|
data/lib/uncruft.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/time'
|
3
|
+
|
1
4
|
require 'uncruft/version'
|
2
5
|
require 'uncruft/railtie'
|
3
6
|
require 'uncruft/deprecation_handler'
|
7
|
+
require 'uncruft/deprecatable'
|
4
8
|
require 'uncruft/warning'
|
5
9
|
|
6
10
|
module Uncruft
|
@@ -8,12 +12,12 @@ module Uncruft
|
|
8
12
|
# http://api.rubyonrails.org/classes/ActiveModel/Type/Boolean.html
|
9
13
|
FALSE_VALUES = [false, 0, "0", "f", "F", "false", "FALSE", "off", "OFF"].to_set
|
10
14
|
|
11
|
-
def
|
12
|
-
ENV['
|
15
|
+
def record_deprecations?
|
16
|
+
ENV['RECORD_DEPRECATIONS'].presence && !ENV['RECORD_DEPRECATIONS'].in?(FALSE_VALUES)
|
13
17
|
end
|
14
18
|
|
15
19
|
def ignorefile_path
|
16
|
-
ENV['UNCRUFT_IGNOREFILE_PATH'] || Rails.root.join('config
|
20
|
+
ENV['UNCRUFT_IGNOREFILE_PATH'] || Rails.root.join('config/deprecations.ignore')
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,9 +5,13 @@ ENV["RAILS_ENV"] ||= 'test'
|
|
5
5
|
require File.expand_path('dummy/config/application', __dir__)
|
6
6
|
require 'support/rails_root'
|
7
7
|
|
8
|
-
Time.zone = ActiveSupport::TimeZone.all.first
|
9
|
-
|
10
8
|
RSpec.configure do |config|
|
11
9
|
config.run_all_when_everything_filtered = true
|
12
10
|
config.example_status_persistence_file_path = 'spec/examples.txt'
|
11
|
+
|
12
|
+
config.around(:all) do |example|
|
13
|
+
Time.use_zone(ActiveSupport::TimeZone.all.first) do
|
14
|
+
example.run
|
15
|
+
end
|
16
|
+
end
|
13
17
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Uncruft::Deprecatable do
|
4
|
+
let(:my_name) { "Jess" }
|
5
|
+
|
6
|
+
subject { klass.new }
|
7
|
+
|
8
|
+
describe '.deprecate_attribute' do
|
9
|
+
let(:klass) do
|
10
|
+
Class.new do
|
11
|
+
include Uncruft::Deprecatable
|
12
|
+
|
13
|
+
attr_accessor :first_name
|
14
|
+
|
15
|
+
deprecate_attribute(:first_name,
|
16
|
+
message: "Please stop using this attribute!")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'applies deprecation warning when setting deprecated attribute' do
|
21
|
+
expect(ActiveSupport::Deprecation).to receive(:warn).once
|
22
|
+
.with("Please stop using this attribute!")
|
23
|
+
|
24
|
+
expect(subject.first_name = my_name).to eq my_name
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'applies deprecation warning when getting deprecated attribute' do
|
28
|
+
subject.instance_variable_set(:@first_name, my_name)
|
29
|
+
|
30
|
+
expect(ActiveSupport::Deprecation).to receive(:warn)
|
31
|
+
.with("Please stop using this attribute!")
|
32
|
+
|
33
|
+
expect(subject.first_name).to eq my_name
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '.deprecate_method' do
|
38
|
+
let(:klass) do
|
39
|
+
Class.new do
|
40
|
+
include Uncruft::Deprecatable
|
41
|
+
|
42
|
+
def legacy_method
|
43
|
+
"Hello Old World!"
|
44
|
+
end
|
45
|
+
|
46
|
+
deprecate_method(:legacy_method,
|
47
|
+
message: "Please stop using this method!")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'applies deprecation warning when calling the deprecated method' do
|
52
|
+
expect(ActiveSupport::Deprecation).to receive(:warn)
|
53
|
+
.with("Please stop using this method!")
|
54
|
+
|
55
|
+
expect(subject.legacy_method).to eq "Hello Old World!"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe Uncruft::DeprecationHandler do
|
4
|
-
let(:ignorefile_path) { Rails.root.join('config
|
4
|
+
let(:ignorefile_path) { Rails.root.join('config/deprecations.ignore') }
|
5
5
|
|
6
6
|
before do
|
7
7
|
File.delete(ignorefile_path) if File.exist?(ignorefile_path)
|
@@ -10,12 +10,12 @@ RSpec.describe Uncruft::DeprecationHandler do
|
|
10
10
|
subject { described_class.new }
|
11
11
|
|
12
12
|
describe '#call' do
|
13
|
-
let(:absolute_path) { Rails.root.join('chicken
|
13
|
+
let(:absolute_path) { Rails.root.join('chicken/nuggets.rb') }
|
14
14
|
let(:line_number) { 123 }
|
15
15
|
let(:caller_label) { '<something>' }
|
16
16
|
let(:message) { "Warning: BAD called from #{caller_label} at #{absolute_path}:#{line_number}" }
|
17
|
-
let(:
|
18
|
-
let(:expected_error) { "#{
|
17
|
+
let(:expected_ignorefile_entry) { 'Warning: BAD called from <something> at chicken/nuggets.rb' }
|
18
|
+
let(:expected_error) { "#{expected_ignorefile_entry}:123" }
|
19
19
|
let(:expected_error_message) do
|
20
20
|
<<~ERROR.strip
|
21
21
|
#{expected_error}
|
@@ -23,7 +23,7 @@ RSpec.describe Uncruft::DeprecationHandler do
|
|
23
23
|
To resolve this error, adjust your code according to the instructions above.
|
24
24
|
If you did not introduce this error or are unsure why you are seeing it,
|
25
25
|
you will find additional guidance at the URL below:
|
26
|
-
https://github.com/Betterment/uncruft/blob/
|
26
|
+
https://github.com/Betterment/uncruft/blob/main/GUIDE.md
|
27
27
|
ERROR
|
28
28
|
end
|
29
29
|
|
@@ -31,14 +31,14 @@ RSpec.describe Uncruft::DeprecationHandler do
|
|
31
31
|
expect { subject.call(message, '') }.to raise_error(RuntimeError, expected_error_message)
|
32
32
|
end
|
33
33
|
|
34
|
-
context 'when
|
34
|
+
context 'when recording new deprecations' do
|
35
35
|
before do
|
36
|
-
allow(Uncruft).to receive(:
|
36
|
+
allow(Uncruft).to receive(:record_deprecations?).and_return(true)
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'sanitizes the message and writes it to the file' do
|
40
40
|
expect { subject.call(message, '') }.to change { File.exist?(ignorefile_path) }.from(false).to(true)
|
41
|
-
expect(File.read(ignorefile_path)).to include(
|
41
|
+
expect(File.read(ignorefile_path)).to include(expected_ignorefile_entry)
|
42
42
|
end
|
43
43
|
|
44
44
|
context 'when timecop is enabled' do
|
@@ -57,7 +57,7 @@ RSpec.describe Uncruft::DeprecationHandler do
|
|
57
57
|
|
58
58
|
context 'when caller is an erb file' do
|
59
59
|
let(:caller_label) { '_app_views_bananas_show__1234_567890' }
|
60
|
-
let(:
|
60
|
+
let(:expected_ignorefile_entry) { 'Warning: BAD called from chicken/nuggets.rb' }
|
61
61
|
|
62
62
|
it 'sanitizes the message and raises an error' do
|
63
63
|
expect { subject.call(message, '') }.to raise_error(RuntimeError, expected_error_message)
|
@@ -66,7 +66,7 @@ RSpec.describe Uncruft::DeprecationHandler do
|
|
66
66
|
|
67
67
|
context 'when caller is "top (required)"' do
|
68
68
|
let(:caller_label) { '<top (required)>' }
|
69
|
-
let(:
|
69
|
+
let(:expected_ignorefile_entry) { 'Warning: BAD called from <global scope> at chicken/nuggets.rb' }
|
70
70
|
|
71
71
|
it 'sanitizes the caller and raises an error' do
|
72
72
|
expect { subject.call(message, '') }.to raise_error(RuntimeError, expected_error_message)
|
@@ -75,7 +75,7 @@ RSpec.describe Uncruft::DeprecationHandler do
|
|
75
75
|
|
76
76
|
context 'when caller is "main"' do
|
77
77
|
let(:caller_label) { '<main>' }
|
78
|
-
let(:
|
78
|
+
let(:expected_ignorefile_entry) { 'Warning: BAD called from <global scope> at chicken/nuggets.rb' }
|
79
79
|
|
80
80
|
it 'sanitizes the caller and raises an error' do
|
81
81
|
expect { subject.call(message, '') }.to raise_error(RuntimeError, expected_error_message)
|
@@ -84,7 +84,7 @@ RSpec.describe Uncruft::DeprecationHandler do
|
|
84
84
|
|
85
85
|
context 'when message includes custom gem path' do
|
86
86
|
let(:absolute_path) { Pathname.new('/banana/banana/banana/gems/chicken/nuggets.rb') }
|
87
|
-
let(:
|
87
|
+
let(:expected_ignorefile_entry) { "Warning: BAD called from <something> at $GEM_PATH/chicken/nuggets.rb" }
|
88
88
|
|
89
89
|
before do
|
90
90
|
allow(ENV).to receive(:[]).and_call_original
|
@@ -104,14 +104,14 @@ RSpec.describe Uncruft::DeprecationHandler do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
context 'when gem is vendored' do
|
107
|
-
let(:absolute_path) { Rails.root.join('vendor
|
107
|
+
let(:absolute_path) { Rails.root.join('vendor/cache/chicken/nuggets.rb') }
|
108
108
|
|
109
109
|
it 'sanitizes the message and raises an error' do
|
110
110
|
expect { subject.call(message, '') }.to raise_error(RuntimeError, expected_error_message)
|
111
111
|
end
|
112
112
|
|
113
113
|
context 'when gem is vendored elsewhere' do
|
114
|
-
let(:absolute_path) { Rails.root.join('
|
114
|
+
let(:absolute_path) { Rails.root.join('../../vendor/cache/chicken/nuggets.rb') }
|
115
115
|
|
116
116
|
it 'sanitizes the message and raises an error' do
|
117
117
|
expect { subject.call(message, '') }.to raise_error(RuntimeError, expected_error_message)
|
@@ -122,14 +122,14 @@ RSpec.describe Uncruft::DeprecationHandler do
|
|
122
122
|
|
123
123
|
context 'when caller is not a filepath' do
|
124
124
|
let(:absolute_path) { '(pry)' }
|
125
|
-
let(:
|
125
|
+
let(:expected_ignorefile_entry) { 'Warning: BAD called from <something> at (pry)' }
|
126
126
|
|
127
127
|
it 'sanitizes the message and raises an error' do
|
128
128
|
expect { subject.call(message, '') }.to raise_error(RuntimeError, expected_error_message)
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
-
context 'when
|
132
|
+
context 'when ignorefile exists' do
|
133
133
|
let(:message) { "Warning: BAD called from #{absolute_path}:#{line_number}" }
|
134
134
|
let(:file_content) do
|
135
135
|
<<~IGNOREFILE
|
@@ -154,11 +154,11 @@ RSpec.describe Uncruft::DeprecationHandler do
|
|
154
154
|
expect { subject.call(message, '') }.not_to change { File.read(ignorefile_path) }
|
155
155
|
end
|
156
156
|
|
157
|
-
context 'when
|
157
|
+
context 'when recording new deprecations' do
|
158
158
|
let(:line_number) { '456' }
|
159
159
|
|
160
160
|
before do
|
161
|
-
allow(Uncruft).to receive(:
|
161
|
+
allow(Uncruft).to receive(:record_deprecations?).and_return(true)
|
162
162
|
end
|
163
163
|
|
164
164
|
it 'does not raise an error and leaves the file intact' do
|
@@ -32,13 +32,13 @@ describe Uncruft::Warning do
|
|
32
32
|
it 'strips out the path so that ActiveSupport::Deprecation can append a new one' do
|
33
33
|
path = caller_locations(0..0).first.path
|
34
34
|
|
35
|
-
|
35
|
+
allow(ActiveSupport::Deprecation).to receive(:warn).with('foo is deprecated!').and_return('hurray')
|
36
36
|
expect(warn("#{path}: foo is deprecated!")).to eq('hurray')
|
37
37
|
|
38
|
-
|
38
|
+
allow(ActiveSupport::Deprecation).to receive(:warn).with('[DEPRECATION] bar is no more.').and_return('huzzah')
|
39
39
|
expect(Kernel.warn("[DEPRECATION] bar is no more. #{path}:#{caller_locations(0..0).first.lineno}")).to eq('huzzah')
|
40
40
|
|
41
|
-
|
41
|
+
allow(ActiveSupport::Deprecation).to receive(:warn).with('Deprecation detected: banana --').and_return('we do our best...')
|
42
42
|
expect(Warning.warn("Deprecation detected: banana -- #{caller(0..0).first}")).to eq('we do our best...')
|
43
43
|
end
|
44
44
|
end
|
data/spec/uncruft_spec.rb
CHANGED
@@ -1,36 +1,36 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe Uncruft do
|
4
|
-
describe '.
|
4
|
+
describe '.record_deprecations?' do
|
5
5
|
it 'handles common truthy and falsy values' do
|
6
|
-
allow(ENV).to receive(:[]).with('
|
7
|
-
expect(described_class.
|
8
|
-
allow(ENV).to receive(:[]).with('
|
9
|
-
expect(described_class.
|
10
|
-
allow(ENV).to receive(:[]).with('
|
11
|
-
expect(described_class.
|
12
|
-
allow(ENV).to receive(:[]).with('
|
13
|
-
expect(described_class.
|
14
|
-
allow(ENV).to receive(:[]).with('
|
15
|
-
expect(described_class.
|
16
|
-
allow(ENV).to receive(:[]).with('
|
17
|
-
expect(described_class.
|
18
|
-
allow(ENV).to receive(:[]).with('
|
19
|
-
expect(described_class.
|
20
|
-
allow(ENV).to receive(:[]).with('
|
21
|
-
expect(described_class.
|
22
|
-
allow(ENV).to receive(:[]).with('
|
23
|
-
expect(described_class.
|
24
|
-
allow(ENV).to receive(:[]).with('
|
25
|
-
expect(described_class.
|
26
|
-
allow(ENV).to receive(:[]).with('
|
27
|
-
expect(described_class.
|
6
|
+
allow(ENV).to receive(:[]).with('RECORD_DEPRECATIONS').and_return('1')
|
7
|
+
expect(described_class.record_deprecations?).to eq true
|
8
|
+
allow(ENV).to receive(:[]).with('RECORD_DEPRECATIONS').and_return('t')
|
9
|
+
expect(described_class.record_deprecations?).to eq true
|
10
|
+
allow(ENV).to receive(:[]).with('RECORD_DEPRECATIONS').and_return('T')
|
11
|
+
expect(described_class.record_deprecations?).to eq true
|
12
|
+
allow(ENV).to receive(:[]).with('RECORD_DEPRECATIONS').and_return('true')
|
13
|
+
expect(described_class.record_deprecations?).to eq true
|
14
|
+
allow(ENV).to receive(:[]).with('RECORD_DEPRECATIONS').and_return('TRUE')
|
15
|
+
expect(described_class.record_deprecations?).to eq true
|
16
|
+
allow(ENV).to receive(:[]).with('RECORD_DEPRECATIONS').and_return('0')
|
17
|
+
expect(described_class.record_deprecations?).to eq false
|
18
|
+
allow(ENV).to receive(:[]).with('RECORD_DEPRECATIONS').and_return('f')
|
19
|
+
expect(described_class.record_deprecations?).to eq false
|
20
|
+
allow(ENV).to receive(:[]).with('RECORD_DEPRECATIONS').and_return('F')
|
21
|
+
expect(described_class.record_deprecations?).to eq false
|
22
|
+
allow(ENV).to receive(:[]).with('RECORD_DEPRECATIONS').and_return('false')
|
23
|
+
expect(described_class.record_deprecations?).to eq false
|
24
|
+
allow(ENV).to receive(:[]).with('RECORD_DEPRECATIONS').and_return('FALSE')
|
25
|
+
expect(described_class.record_deprecations?).to eq false
|
26
|
+
allow(ENV).to receive(:[]).with('RECORD_DEPRECATIONS').and_return('')
|
27
|
+
expect(described_class.record_deprecations?).to be_nil
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
describe '.ignorefile_path' do
|
32
32
|
it 'uses rails root' do
|
33
|
-
expect(described_class.ignorefile_path).to eq(Rails.root.join('config
|
33
|
+
expect(described_class.ignorefile_path).to eq(Rails.root.join('config/deprecations.ignore'))
|
34
34
|
end
|
35
35
|
|
36
36
|
context 'when env var is set' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uncruft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Griffith
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-01-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 5.2.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 5.2.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: appraisal
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 2.2.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: betterlint
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
@@ -54,33 +54,33 @@ dependencies:
|
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: rails
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- - "
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
62
|
+
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - "
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: rspec
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: 3.7.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
83
|
+
version: 3.7.0
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: timecop
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,15 +107,15 @@ files:
|
|
107
107
|
- README.md
|
108
108
|
- Rakefile
|
109
109
|
- lib/uncruft.rb
|
110
|
+
- lib/uncruft/deprecatable.rb
|
110
111
|
- lib/uncruft/deprecation_handler.rb
|
111
112
|
- lib/uncruft/railtie.rb
|
112
113
|
- lib/uncruft/version.rb
|
113
114
|
- lib/uncruft/warning.rb
|
114
115
|
- spec/dummy/config/application.rb
|
115
|
-
- spec/dummy/config/deprecations.ignore
|
116
|
-
- spec/examples.txt
|
117
116
|
- spec/spec_helper.rb
|
118
117
|
- spec/support/rails_root.rb
|
118
|
+
- spec/uncruft/deprecatable_spec.rb
|
119
119
|
- spec/uncruft/deprecation_handler_spec.rb
|
120
120
|
- spec/uncruft/railtie_spec.rb
|
121
121
|
- spec/uncruft/warning_spec.rb
|
@@ -123,7 +123,8 @@ files:
|
|
123
123
|
homepage: https://github.com/Betterment/uncruft
|
124
124
|
licenses:
|
125
125
|
- MIT
|
126
|
-
metadata:
|
126
|
+
metadata:
|
127
|
+
rubygems_mfa_required: 'true'
|
127
128
|
post_install_message:
|
128
129
|
rdoc_options: []
|
129
130
|
require_paths:
|
@@ -132,24 +133,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
133
|
requirements:
|
133
134
|
- - ">="
|
134
135
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
136
|
+
version: 2.6.0
|
136
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
138
|
requirements:
|
138
139
|
- - ">="
|
139
140
|
- !ruby/object:Gem::Version
|
140
141
|
version: '0'
|
141
142
|
requirements: []
|
142
|
-
rubygems_version: 3.
|
143
|
+
rubygems_version: 3.1.6
|
143
144
|
signing_key:
|
144
145
|
specification_version: 4
|
145
146
|
summary: A library to assist with Rails upgrades
|
146
147
|
test_files:
|
147
148
|
- spec/spec_helper.rb
|
148
|
-
- spec/dummy/config/deprecations.ignore
|
149
149
|
- spec/dummy/config/application.rb
|
150
|
-
- spec/examples.txt
|
151
150
|
- spec/uncruft/railtie_spec.rb
|
152
151
|
- spec/uncruft/warning_spec.rb
|
152
|
+
- spec/uncruft/deprecatable_spec.rb
|
153
153
|
- spec/uncruft/deprecation_handler_spec.rb
|
154
154
|
- spec/support/rails_root.rb
|
155
155
|
- spec/uncruft_spec.rb
|
data/spec/examples.txt
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
example_id | status | run_time |
|
2
|
-
------------------------------------------------------- | ------ | --------------- |
|
3
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:1] | passed | 0.00273 seconds |
|
4
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:2:1] | passed | 0.01668 seconds |
|
5
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:2:2:1] | passed | 0.00367 seconds |
|
6
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:3:1] | passed | 0.00155 seconds |
|
7
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:4:1] | passed | 0.00321 seconds |
|
8
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:5:1] | passed | 0.00102 seconds |
|
9
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:6:1] | passed | 0.00113 seconds |
|
10
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:6:2:1] | passed | 0.00101 seconds |
|
11
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:6:3:1] | passed | 0.00149 seconds |
|
12
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:6:3:2:1] | passed | 0.00167 seconds |
|
13
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:7:1] | passed | 0.00084 seconds |
|
14
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:8:1] | passed | 0.004 seconds |
|
15
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:8:2:1] | passed | 0.00316 seconds |
|
16
|
-
./spec/uncruft/railtie_spec.rb[1:1] | passed | 0.05893 seconds |
|
17
|
-
./spec/uncruft/railtie_spec.rb[1:2:1] | passed | 0.00132 seconds |
|
18
|
-
./spec/uncruft/railtie_spec.rb[1:3:1] | passed | 0.00124 seconds |
|
19
|
-
./spec/uncruft/warning_spec.rb[1:1] | passed | 0.00042 seconds |
|
20
|
-
./spec/uncruft/warning_spec.rb[1:2] | passed | 0.00014 seconds |
|
21
|
-
./spec/uncruft/warning_spec.rb[1:3:1] | passed | 0.00077 seconds |
|
22
|
-
./spec/uncruft/warning_spec.rb[1:3:2:1] | passed | 0.00059 seconds |
|
23
|
-
./spec/uncruft_spec.rb[1:1:1] | passed | 0.00281 seconds |
|
24
|
-
./spec/uncruft_spec.rb[1:2:1] | passed | 0.00027 seconds |
|
25
|
-
./spec/uncruft_spec.rb[1:2:2:1] | passed | 0.0003 seconds |
|