uncruft 0.0.2 → 0.1.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 +7 -7
- data/lib/uncruft.rb +2 -2
- data/lib/uncruft/deprecation_handler.rb +1 -1
- data/lib/uncruft/version.rb +1 -1
- data/lib/uncruft/warning.rb +1 -1
- data/spec/examples.txt +23 -23
- data/spec/uncruft/deprecation_handler_spec.rb +13 -13
- data/spec/uncruft_spec.rb +23 -23
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 872b086c546d40b77f15ad5151c489ed5252650933a973cb6d8c4c8875c6e34c
|
4
|
+
data.tar.gz: dc4827ef98f9074dfb8fd69cc2f9b65a5c748ede3c8c170cf05e941c8118f438
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc79959ad5e277af441da4078096c364fe0d2da1b1dcc4edf669a0c8531a26a6412d185c424aedabe204a1699d34abdfa251de919f83ad74add09c37c5632bf8
|
7
|
+
data.tar.gz: dec28f5ebf6cbfffa6c5c4d1b0afbd5b363fce562c6dfed8c62b374d064ac9d47e5382ed1b7c486098edfb1c089058bafb52ba517a202328b698f6d2200d2d09
|
data/README.md
CHANGED
@@ -23,22 +23,22 @@ By default, deprecation warnings will cause your application to raise exceptions
|
|
23
23
|
|
24
24
|
The exception message will include the original deprecation warning, plus a link to [our troubleshooting guide](https://github.com/Betterment/uncruft/blob/master/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
|
-
This will generate (or add to) a whitelist of warnings at `config/deprecations.ignore`. Any warning in that file will be ignored when next encountered.
|
41
|
-
|
42
42
|
## How to Contribute
|
43
43
|
|
44
44
|
We would love for you to contribute! Anything that benefits the majority of users—from a documentation fix to an entirely new feature—is encouraged.
|
data/lib/uncruft.rb
CHANGED
@@ -8,8 +8,8 @@ module Uncruft
|
|
8
8
|
# http://api.rubyonrails.org/classes/ActiveModel/Type/Boolean.html
|
9
9
|
FALSE_VALUES = [false, 0, "0", "f", "F", "false", "FALSE", "off", "OFF"].to_set
|
10
10
|
|
11
|
-
def
|
12
|
-
ENV['
|
11
|
+
def record_deprecations?
|
12
|
+
ENV['RECORD_DEPRECATIONS'].presence && !FALSE_VALUES.include?(ENV['RECORD_DEPRECATIONS'])
|
13
13
|
end
|
14
14
|
|
15
15
|
def ignorefile_path
|
data/lib/uncruft/version.rb
CHANGED
data/lib/uncruft/warning.rb
CHANGED
data/spec/examples.txt
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
example_id | status | run_time |
|
2
2
|
------------------------------------------------------- | ------ | --------------- |
|
3
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:1] | passed | 0.
|
4
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:2:1] | passed | 0.
|
5
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:2:2:1] | passed | 0.
|
6
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:3:1] | passed | 0.
|
7
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:4:1] | passed | 0.
|
8
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:5:1] | passed | 0.
|
9
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:6:1] | passed | 0.
|
10
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:6:2:1] | passed | 0.
|
11
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:6:3:1] | passed | 0.
|
12
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:6:3:2:1] | passed | 0.
|
13
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:7:1] | passed | 0.
|
14
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:8:1] | passed | 0.
|
15
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:8:2:1] | passed | 0.
|
16
|
-
./spec/uncruft/railtie_spec.rb[1:1] | passed | 0.
|
17
|
-
./spec/uncruft/railtie_spec.rb[1:2:1] | passed | 0.
|
18
|
-
./spec/uncruft/railtie_spec.rb[1:3:1] | passed | 0.
|
19
|
-
./spec/uncruft/warning_spec.rb[1:1] | passed | 0.
|
20
|
-
./spec/uncruft/warning_spec.rb[1:2] | passed | 0.
|
21
|
-
./spec/uncruft/warning_spec.rb[1:3:1] | passed | 0.
|
22
|
-
./spec/uncruft/warning_spec.rb[1:3:2:1] | passed | 0.
|
23
|
-
./spec/uncruft_spec.rb[1:1:1] | passed | 0.
|
24
|
-
./spec/uncruft_spec.rb[1:2:1] | passed | 0.
|
25
|
-
./spec/uncruft_spec.rb[1:2:2:1] | passed | 0.
|
3
|
+
./spec/uncruft/deprecation_handler_spec.rb[1:1:1] | passed | 0.00192 seconds |
|
4
|
+
./spec/uncruft/deprecation_handler_spec.rb[1:1:2:1] | passed | 0.01722 seconds |
|
5
|
+
./spec/uncruft/deprecation_handler_spec.rb[1:1:2:2:1] | passed | 0.00547 seconds |
|
6
|
+
./spec/uncruft/deprecation_handler_spec.rb[1:1:3:1] | passed | 0.00071 seconds |
|
7
|
+
./spec/uncruft/deprecation_handler_spec.rb[1:1:4:1] | passed | 0.00092 seconds |
|
8
|
+
./spec/uncruft/deprecation_handler_spec.rb[1:1:5:1] | passed | 0.00093 seconds |
|
9
|
+
./spec/uncruft/deprecation_handler_spec.rb[1:1:6:1] | passed | 0.00258 seconds |
|
10
|
+
./spec/uncruft/deprecation_handler_spec.rb[1:1:6:2:1] | passed | 0.00365 seconds |
|
11
|
+
./spec/uncruft/deprecation_handler_spec.rb[1:1:6:3:1] | passed | 0.00157 seconds |
|
12
|
+
./spec/uncruft/deprecation_handler_spec.rb[1:1:6:3:2:1] | passed | 0.00173 seconds |
|
13
|
+
./spec/uncruft/deprecation_handler_spec.rb[1:1:7:1] | passed | 0.00068 seconds |
|
14
|
+
./spec/uncruft/deprecation_handler_spec.rb[1:1:8:1] | passed | 0.00156 seconds |
|
15
|
+
./spec/uncruft/deprecation_handler_spec.rb[1:1:8:2:1] | passed | 0.00124 seconds |
|
16
|
+
./spec/uncruft/railtie_spec.rb[1:1] | passed | 0.04512 seconds |
|
17
|
+
./spec/uncruft/railtie_spec.rb[1:2:1] | passed | 0.00231 seconds |
|
18
|
+
./spec/uncruft/railtie_spec.rb[1:3:1] | passed | 0.00558 seconds |
|
19
|
+
./spec/uncruft/warning_spec.rb[1:1] | passed | 0.00152 seconds |
|
20
|
+
./spec/uncruft/warning_spec.rb[1:2] | passed | 0.00101 seconds |
|
21
|
+
./spec/uncruft/warning_spec.rb[1:3:1] | passed | 0.00387 seconds |
|
22
|
+
./spec/uncruft/warning_spec.rb[1:3:2:1] | passed | 0.00112 seconds |
|
23
|
+
./spec/uncruft_spec.rb[1:1:1] | passed | 0.00506 seconds |
|
24
|
+
./spec/uncruft_spec.rb[1:2:1] | passed | 0.00101 seconds |
|
25
|
+
./spec/uncruft_spec.rb[1:2:2:1] | passed | 0.00036 seconds |
|
@@ -14,8 +14,8 @@ RSpec.describe Uncruft::DeprecationHandler do
|
|
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}
|
@@ -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
|
@@ -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
|
data/spec/uncruft_spec.rb
CHANGED
@@ -1,30 +1,30 @@
|
|
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
|
|
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.1.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: 2020-01-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -71,16 +71,16 @@ dependencies:
|
|
71
71
|
name: rubocop-betterment
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - "
|
74
|
+
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: '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: '0'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: timecop
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
|
-
rubygems_version: 3.
|
142
|
+
rubygems_version: 3.1.2
|
143
143
|
signing_key:
|
144
144
|
specification_version: 4
|
145
145
|
summary: A library to assist with Rails upgrades
|