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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ced48d12c51461c2bb713dcfce5b86b592f839f88effc936dace865badbcd0a
4
- data.tar.gz: d917c8000e483c30cc0cb4a94049416c88b5eadcd5ba959ed855c64d765c212d
3
+ metadata.gz: 872b086c546d40b77f15ad5151c489ed5252650933a973cb6d8c4c8875c6e34c
4
+ data.tar.gz: dc4827ef98f9074dfb8fd69cc2f9b65a5c748ede3c8c170cf05e941c8118f438
5
5
  SHA512:
6
- metadata.gz: daf0967137adbd0c821f8237b9419cb672be5b12d2ab6b69a2d4d15d5763312de31591424fcbebf97686515ecb69327179a0b3a225145eb04af93ab727a52d0d
7
- data.tar.gz: f2839f2318ead9bbe0bf454a7d22237b19d4ab6ea94566f3837952587cb6769ad31baf4cd9f86c4b295805a065d203cbebe544c6e29ab7e6dbf98ef487e8aacc
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
- ## Whitelisting Deprecations
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 whitelist all existing deprecation warnings encountered during your test suite like so:
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
- WHITELIST_DEPRECATIONS=1 rake
31
+ RECORD_DEPRECATIONS=1 rake
32
32
  ```
33
33
 
34
- You can also incrementally add new warnings to the whitelist as you encounter them:
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
- WHITELIST_DEPRECATIONS=1 rspec path/to/my/failing/spec.rb
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 whitelist_deprecations?
12
- ENV['WHITELIST_DEPRECATIONS'].presence && !FALSE_VALUES.include?(ENV['WHITELIST_DEPRECATIONS'])
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
@@ -15,7 +15,7 @@ module Uncruft
15
15
  private
16
16
 
17
17
  def handle_unknown_deprecation!(message, line_number)
18
- if Uncruft.whitelist_deprecations?
18
+ if Uncruft.record_deprecations?
19
19
  known_deprecations << message
20
20
  write_deprecations_file!
21
21
  else
@@ -1,3 +1,3 @@
1
1
  module Uncruft
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '0.1.0'.freeze
3
3
  end
@@ -1,6 +1,6 @@
1
1
  module Uncruft
2
2
  module Warning
3
- DEPRECATION_PATTERN = /(deprecation|deprecated)/i
3
+ DEPRECATION_PATTERN = /(deprecation|deprecated)/i.freeze
4
4
 
5
5
  def warn(str, *args)
6
6
  if str =~ DEPRECATION_PATTERN # rubocop:disable Performance/RegexpMatch
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.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 |
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(:expected_whitelist_entry) { 'Warning: BAD called from <something> at chicken/nuggets.rb' }
18
- let(:expected_error) { "#{expected_whitelist_entry}:123" }
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 whitelisting new deprecations' do
34
+ context 'when recording new deprecations' do
35
35
  before do
36
- allow(Uncruft).to receive(:whitelist_deprecations?).and_return(true)
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(expected_whitelist_entry)
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(:expected_whitelist_entry) { 'Warning: BAD called from chicken/nuggets.rb' }
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(:expected_whitelist_entry) { 'Warning: BAD called from <global scope> at chicken/nuggets.rb' }
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(:expected_whitelist_entry) { 'Warning: BAD called from <global scope> at chicken/nuggets.rb' }
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(:expected_whitelist_entry) { "Warning: BAD called from <something> at $GEM_PATH/chicken/nuggets.rb" }
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(:expected_whitelist_entry) { 'Warning: BAD called from <something> at (pry)' }
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 whitelist exists' do
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 whitelisting new deprecations' do
157
+ context 'when recording new deprecations' do
158
158
  let(:line_number) { '456' }
159
159
 
160
160
  before do
161
- allow(Uncruft).to receive(:whitelist_deprecations?).and_return(true)
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 '.whitelist_deprecations?' do
4
+ describe '.record_deprecations?' do
5
5
  it 'handles common truthy and falsy values' do
6
- allow(ENV).to receive(:[]).with('WHITELIST_DEPRECATIONS').and_return('1')
7
- expect(described_class.whitelist_deprecations?).to eq true
8
- allow(ENV).to receive(:[]).with('WHITELIST_DEPRECATIONS').and_return('t')
9
- expect(described_class.whitelist_deprecations?).to eq true
10
- allow(ENV).to receive(:[]).with('WHITELIST_DEPRECATIONS').and_return('T')
11
- expect(described_class.whitelist_deprecations?).to eq true
12
- allow(ENV).to receive(:[]).with('WHITELIST_DEPRECATIONS').and_return('true')
13
- expect(described_class.whitelist_deprecations?).to eq true
14
- allow(ENV).to receive(:[]).with('WHITELIST_DEPRECATIONS').and_return('TRUE')
15
- expect(described_class.whitelist_deprecations?).to eq true
16
- allow(ENV).to receive(:[]).with('WHITELIST_DEPRECATIONS').and_return('0')
17
- expect(described_class.whitelist_deprecations?).to eq false
18
- allow(ENV).to receive(:[]).with('WHITELIST_DEPRECATIONS').and_return('f')
19
- expect(described_class.whitelist_deprecations?).to eq false
20
- allow(ENV).to receive(:[]).with('WHITELIST_DEPRECATIONS').and_return('F')
21
- expect(described_class.whitelist_deprecations?).to eq false
22
- allow(ENV).to receive(:[]).with('WHITELIST_DEPRECATIONS').and_return('false')
23
- expect(described_class.whitelist_deprecations?).to eq false
24
- allow(ENV).to receive(:[]).with('WHITELIST_DEPRECATIONS').and_return('FALSE')
25
- expect(described_class.whitelist_deprecations?).to eq false
26
- allow(ENV).to receive(:[]).with('WHITELIST_DEPRECATIONS').and_return('')
27
- expect(described_class.whitelist_deprecations?).to be_nil
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.2
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: 2019-06-07 00:00:00.000000000 Z
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: 1.1.1
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: 1.1.1
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.0.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