deprecations 2.0.4 → 2.2.2

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: d98430ec3094db3b30af3b96a693db71e2968d3fa2dda4fb92bdaacf67e0e8f8
4
- data.tar.gz: 0bf5b46d38582b06aa63fc697b46539a44b376d4b207ce495e305fe70e587753
3
+ metadata.gz: 976d65184fd1442180e364ecd885aabf9202877f1bb7d11c1315eed9fe30b5ee
4
+ data.tar.gz: bf4ad1bc538b49878a6268321883d1d89a3cc3fe0627ef8c2d37200972c22ad2
5
5
  SHA512:
6
- metadata.gz: 8ef90c37e7050de756e4f1c463be6813aedc2b4d24e374938d4ce29d744dabe11fd64d721c6ac2cd3493b8c76f1401ff4c73f7e00c09e152ab90f03e89892f55
7
- data.tar.gz: '045540686602609ee4bf04ff1a862b5cb9f1da9027d839d55da66a458caaa8f7ac94404879c0cb5c33a002387a8df49f083987c73a62319ebeb554557e3a3baa'
6
+ metadata.gz: 29383bc82baad099e0597f6efb0c4a0e2d4bb7f87e2235c19e1ebd58e0611c287aa7b1f478c1e75fc942f43bd2078cfb09f80f90df72ab4d184012e2dee8a51d
7
+ data.tar.gz: 0636b27fc0c83e46df73364b669b6c59f0c2e844e424807a990ee45d8bf1957b93db289d744d63013b099317f8f23618aa92b979c468a200712608956bd220a7
data/README.md CHANGED
@@ -52,7 +52,7 @@ end
52
52
 
53
53
  Whenever the method `MySample#clean` is called this warning appears:
54
54
 
55
- > [DEPRECATION] `MySample#clean` is deprecated and will be outdated next version. Please use `MySample#clear` instead.
55
+ > warning: `MySample#clean` is deprecated and will be outdated next version. Please use `MySample#clear` instead.
56
56
 
57
57
  Marking a complete class as deprecated will present the deprecation warning whenever this class is instantiated:
58
58
 
@@ -89,7 +89,7 @@ Any object responding to `#call` will be accepted as a valid handler.
89
89
  Whenever you need to temporary change the standard behavior (like e.g. in your specs) you can do this like
90
90
 
91
91
  ```ruby
92
- Deprecations.set_behavior(:silent) do
92
+ Deprecations.with_behavior(:silent) do
93
93
  MyDeprecatedClass.new.do_some_magic
94
94
  end
95
95
  ```
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Deprecations
2
4
  class << self
3
5
  def behavior
4
6
  BEHAVIOR.key(@behavior) || @behavior
5
7
  end
6
8
 
7
- def behavior=(behavior)
8
- @behavior = as_behavior(behavior)
9
+ def behavior=(value)
10
+ @behavior = as_behavior(value)
9
11
  end
10
12
 
11
- def set_behavior(behavior)
13
+ def with_behavior(behavior)
12
14
  behavior = as_behavior(behavior)
13
15
  raise(ArgumentError, 'block expected') unless block_given?
14
16
  current_behavior = @behavior
@@ -20,6 +22,8 @@ module Deprecations
20
22
  end
21
23
  end
22
24
 
25
+ alias set_behavior with_behavior
26
+
23
27
  private
24
28
 
25
29
  def as_behavior(arg)
@@ -27,7 +31,7 @@ module Deprecations
27
31
  BEHAVIOR.fetch(arg) do
28
32
  raise(
29
33
  ArgumentError,
30
- 'invalid parameter - behavior has to be' \
34
+ 'invalid parameter - behavior has to be ' \
31
35
  "#{valid_behaviors} or need to respond to `call`"
32
36
  )
33
37
  end
@@ -42,22 +46,20 @@ module Deprecations
42
46
  msg = "`#{subject}` is deprecated"
43
47
  msg << " - use #{alternative} instead" if alternative
44
48
  ex = Error.new(msg)
45
- ex.set_backtrace(caller(4))
49
+ ex.set_backtrace(caller(3))
46
50
  raise(ex)
47
51
  end
48
52
  end
49
53
 
50
54
  module Warn
51
55
  def self.call(subject, alternative, outdated)
52
- location = caller_locations(4, 1)[-1]
53
- location = "#{location.path}:#{location.lineno}: " if location
54
- msg = "#{location}[DEPRECATION] `#{subject}` is deprecated"
56
+ msg = "`#{subject}` is deprecated"
55
57
  msg << (outdated ? " and will be outdated #{outdated}." : '.')
56
58
  msg << " Please use `#{alternative}` instead." if alternative
57
- ::Kernel.warn(msg)
59
+ ::Kernel.warn(msg, uplevel: 3)
58
60
  end
59
61
  end
60
62
 
61
- BEHAVIOR = {silence: ->(*){ }, raise: Raise, warn: Warn}
63
+ BEHAVIOR = { silence: proc {}, raise: Raise, warn: Warn }.freeze
62
64
  end
63
65
  end
@@ -1,6 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Deprecations
2
4
  class << self
3
5
  private
6
+
4
7
  def infect(mod)
5
8
  mod.extend(ClassMethods)
6
9
  mod.send(:include, InstanceMethods)
@@ -8,8 +11,13 @@ module Deprecations
8
11
 
9
12
  module Helper
10
13
  private
14
+
11
15
  def __method(method_name)
12
- instance_method(method_name) rescue nil
16
+ begin
17
+ instance_method(method_name)
18
+ rescue StandardError
19
+ nil
20
+ end
13
21
  end
14
22
 
15
23
  def __method_deprecated!(method, alternative, outdated)
@@ -17,16 +25,23 @@ module Deprecations
17
25
  undef_method(method.name)
18
26
  define_method(method.name) do |*a, &b|
19
27
  decorated = Class === self ? "#{self}." : "#{defining_context}#"
20
- alternative = "#{decorated}#{alternative.name}" if UnboundMethod === alternative
21
- Deprecations.call("#{decorated}#{::Kernel.__method__}", alternative, outdated)
28
+ alternative = "#{decorated}#{alternative.name}" if UnboundMethod ===
29
+ alternative
30
+ Deprecations.call(
31
+ "#{decorated}#{::Kernel.__method__}",
32
+ alternative,
33
+ outdated
34
+ )
22
35
  method.bind(self).call(*a, &b)
23
36
  end
24
37
  end
25
38
 
26
39
  def __method_checked(method_name)
27
- __method(method_name) or raise(
28
- NameError, "undefined method `#{method_name}` for class `#{self}`"
29
- )
40
+ __method(method_name) or
41
+ raise(
42
+ NameError,
43
+ "undefined method `#{method_name}` for class `#{self}`"
44
+ )
30
45
  end
31
46
 
32
47
  def __method_alternative(alternative)
@@ -36,6 +51,7 @@ module Deprecations
36
51
 
37
52
  module ClassMethods
38
53
  private
54
+
39
55
  include Helper
40
56
 
41
57
  def deprecated(method_name, alternative = nil, outdated = nil)
@@ -49,12 +65,19 @@ module Deprecations
49
65
 
50
66
  module InstanceMethods
51
67
  private
68
+
52
69
  include Helper
53
70
 
54
71
  def deprecated(method_name, alternative = nil, outdated = nil)
55
- m = __method(method_name) or return singleton_class.send(
56
- :deprecated, method_name, alternative, outdated
57
- )
72
+ m = __method(method_name) or
73
+ return(
74
+ singleton_class.send(
75
+ :deprecated,
76
+ method_name,
77
+ alternative,
78
+ outdated
79
+ )
80
+ )
58
81
  __method_deprecated!(m, __method_alternative(alternative), outdated)
59
82
  end
60
83
 
@@ -66,7 +89,6 @@ module Deprecations
66
89
  end
67
90
  end
68
91
  end
69
-
70
92
  end
71
93
 
72
94
  infect(Module)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Deprecations
2
- VERSION = '2.0.4'
4
+ VERSION = '2.2.2'
3
5
  end
data/lib/deprecations.rb CHANGED
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Deprecations
2
- autoload(:VERSION, "#{__FILE__[/.*(?=\..+$)/]}/version")
4
+ require_relative 'deprecations/version'
3
5
  require_relative 'deprecations/extension'
4
6
  require_relative 'deprecations/behavior'
5
7
 
metadata CHANGED
@@ -1,97 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deprecations
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Blumtritt
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-13 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.11'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.11'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '10.1'
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 10.1.1
37
- type: :development
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - "~>"
42
- - !ruby/object:Gem::Version
43
- version: '10.1'
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 10.1.1
47
- - !ruby/object:Gem::Dependency
48
- name: rspec
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '3.0'
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: 3.0.0
57
- type: :development
58
- prerelease: false
59
- version_requirements: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - "~>"
62
- - !ruby/object:Gem::Version
63
- version: '3.0'
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: 3.0.0
11
+ date: 2022-07-30 00:00:00.000000000 Z
12
+ dependencies: []
67
13
  description: |
68
14
  This gem provides transparent declaration of deprecated methods and classes.
69
15
  It's easy, small, has no dependencies and no overhead.
70
- email: mike.blumtritt@invision.de
16
+ email:
71
17
  executables: []
72
18
  extensions: []
73
19
  extra_rdoc_files:
74
20
  - README.md
75
21
  files:
76
- - ".gitignore"
77
- - Gemfile
78
- - Guardfile
79
22
  - README.md
80
- - Rakefile
81
- - deprecations.gemspec
82
23
  - lib/deprecations.rb
83
24
  - lib/deprecations/behavior.rb
84
25
  - lib/deprecations/extension.rb
85
26
  - lib/deprecations/version.rb
86
- - spec/deprecations/behavior_spec.rb
87
- - spec/deprecations/version_spec.rb
88
- - spec/deprecations_spec.rb
89
- - spec/spec_helper.rb
90
27
  homepage: https://github.com/mblumtritt/deprecations
91
28
  licenses: []
92
29
  metadata:
93
- issue_tracker: https://github.com/mblumtritt/deprecations/issues
94
- post_install_message:
30
+ source_code_uri: https://github.com/mblumtritt/deprecations
31
+ bug_tracker_uri: https://github.com/mblumtritt/deprecations/issues
32
+ post_install_message:
95
33
  rdoc_options: []
96
34
  require_paths:
97
35
  - lib
@@ -104,15 +42,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
42
  requirements:
105
43
  - - ">="
106
44
  - !ruby/object:Gem::Version
107
- version: 1.3.6
45
+ version: '0'
108
46
  requirements: []
109
- rubyforge_project: deprecations
110
- rubygems_version: 2.7.6
111
- signing_key:
47
+ rubygems_version: 3.3.7
48
+ signing_key:
112
49
  specification_version: 4
113
50
  summary: Deprecation support for your project.
114
- test_files:
115
- - spec/deprecations/behavior_spec.rb
116
- - spec/deprecations/version_spec.rb
117
- - spec/deprecations_spec.rb
118
- - spec/spec_helper.rb
51
+ test_files: []
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- tmp/
2
- local/
3
- pkg/
4
- coverage/
5
- Gemfile.lock
data/Gemfile DELETED
@@ -1 +0,0 @@
1
- source('https://rubygems.org'){ gemspec }
data/Guardfile DELETED
@@ -1,12 +0,0 @@
1
- guard(
2
- :rspec,
3
- cmd: 'bundle exec rspec -c',
4
- spec_paths: ['spec'],
5
- failed_mode: :focus,
6
- all_on_start: true,
7
- all_after_pass: true
8
- ) do
9
- watch(%r{^spec/.+_spec.rb$})
10
- watch(%r{^lib/.+.rb$}){ 'spec' }
11
- watch(%r{^spec/spec_helper}){ 'spec' }
12
- end
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:test) do |t|
5
- t.pattern = ['spec/*_spec.rb', 'spec/**/*/*_spec.rb']
6
- t.rspec_opts = '-w'
7
- t.verbose = Rake.application.options.trace
8
- end
9
-
10
- task default: :test
data/deprecations.gemspec DELETED
@@ -1,32 +0,0 @@
1
- require File.expand_path('../lib/deprecations/version', __FILE__)
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = spec.rubyforge_project = 'deprecations'
5
- spec.version = Deprecations::VERSION
6
- spec.summary = 'Deprecation support for your project.'
7
- spec.description = <<~EOS
8
- This gem provides transparent declaration of deprecated methods and classes.
9
- It's easy, small, has no dependencies and no overhead.
10
- EOS
11
- spec.author = 'Mike Blumtritt'
12
- spec.email = 'mike.blumtritt@invision.de'
13
- spec.homepage = 'https://github.com/mblumtritt/deprecations'
14
- spec.metadata = {'issue_tracker' => 'https://github.com/mblumtritt/deprecations/issues'}
15
-
16
- spec.add_development_dependency 'bundler', '~> 1.11'
17
- spec.add_development_dependency 'rake', '~> 10.1', '>= 10.1.1'
18
- spec.add_development_dependency 'rspec', '~> 3.0', '>= 3.0.0'
19
-
20
- spec.platform = Gem::Platform::RUBY
21
- spec.required_ruby_version = '>= 2.0.0'
22
- spec.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
23
-
24
- spec.require_paths = %w[lib]
25
-
26
- all_files = %x(git ls-files -z).split(0.chr)
27
- spec.test_files = all_files.grep(%r{^(spec|test)/})
28
- spec.files = all_files - spec.test_files
29
-
30
- spec.has_rdoc = false
31
- spec.extra_rdoc_files = %w(README.md)
32
- end
@@ -1,98 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Deprecations do
4
- context 'behavior' do
5
-
6
- it 'is possible to configure the behavior with a pre-defined value' do
7
- %i(silence raise warn).each do |behavior|
8
- Deprecations.behavior = behavior
9
- expect(Deprecations.behavior).to be(behavior)
10
- end
11
- end
12
-
13
- it 'is possible to configure a custom behavior' do
14
- custom = proc do |*args|
15
- FantasticLogger.log(*args)
16
- end
17
- Deprecations.behavior = custom
18
- expect(Deprecations.behavior).to be(custom)
19
- end
20
-
21
- context 'standard behavior :silence' do
22
- before do
23
- Deprecations.behavior = :silence
24
- end
25
-
26
- it 'does simply nothing' do
27
- expect(subject.call(*%w(should be silent))).to be(subject)
28
- end
29
- end
30
-
31
- context 'standard behavior :warn' do
32
- before do
33
- Deprecations.behavior = :warn
34
- end
35
- after do
36
- Deprecations.call('Bad#method', 'Bad#alternative', 'after next version')
37
- end
38
-
39
- it 'warns about the deprecation' do
40
- expect(Kernel).to receive(:warn).once.with(/DEPRECATION/)
41
- end
42
-
43
- it 'points to the deprecated method' do
44
- expect(Kernel).to receive(:warn).once.with(/Bad#method.*deprecated/)
45
- end
46
-
47
- it 'suggests the alternative method' do
48
- expect(Kernel).to receive(:warn).once.with(/Bad#alternative.*instead/)
49
- end
50
-
51
- it 'contains information about when it will not longer supported' do
52
- expect(Kernel).to receive(:warn).once.with(/outdated after next version/)
53
- end
54
- end
55
-
56
- context 'standard behavior :raise' do
57
- before do
58
- Deprecations.behavior = :raise
59
- end
60
- subject{ Deprecations.call('Bad#method', 'Bad#alternative', 'after next version') }
61
-
62
- it 'raises a Deprecations::Error' do
63
- expect{ subject }.to raise_error(Deprecations::Error)
64
- end
65
-
66
- it 'points to the deprecated method' do
67
- expect{ subject }.to raise_error(Deprecations::Error, /Bad#method.*deprecated/)
68
- end
69
-
70
- it 'suggests the alternative method' do
71
- expect{ subject }.to raise_error(Deprecations::Error, /Bad#alternative.*instead/)
72
- end
73
- end
74
-
75
- context 'change behavior temporary' do
76
- let(:sample_class) do
77
- Class.new(BasicObject) do
78
- deprecated!
79
- end
80
- end
81
-
82
- before do
83
- Deprecations.behavior = :raise
84
- end
85
-
86
- after do
87
- Deprecations.set_behavior(:warn) do
88
- sample_class.new.__id__
89
- end
90
- end
91
-
92
- it 'is possible to temporary use a different behavior' do
93
- expect(Kernel).to receive(:warn).once
94
- end
95
-
96
- end
97
- end
98
- end
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe 'Deprecations::VERSION' do
4
- it 'has format <major>.<minor>.<build>' do
5
- expect(Deprecations::VERSION).to match(/^\d{1,2}\.\d{1,2}\.\d{1,3}/)
6
- end
7
- end
@@ -1,235 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Deprecations do
4
- context 'policy' do
5
- before do
6
- Deprecations.behavior = :silence
7
- end
8
-
9
- context 'parameter forwarding' do
10
-
11
- context 'when an instance method is marked as deprecated' do
12
- subject do
13
- Class.new(BasicObject) do
14
- def foo(*args)
15
- {foo: args}
16
- end
17
- deprecated :foo
18
- end
19
- end
20
-
21
- it 'forwards all parameters and returns the original method`s result' do
22
- result = subject.new.foo(:arg1, :arg2, 42)
23
- expect(result).to eq(foo: [:arg1, :arg2, 42])
24
- end
25
- end
26
-
27
- context 'when a class method is marked as deprecated' do
28
- subject do
29
- Class.new(BasicObject) do
30
- def self.foo(*args)
31
- {foo: args}
32
- end
33
- deprecated :foo
34
- end
35
- end
36
-
37
- it 'forwards all parameters and returns the original method`s result' do
38
- result = subject.foo(:arg1, :arg2, 42)
39
- expect(result).to eq(foo: [:arg1, :arg2, 42])
40
- end
41
- end
42
-
43
- context 'when a class is marked as deprecated' do
44
- subject do
45
- Class.new(BasicObject) do
46
- attr_reader :parameters
47
- def initialize(*parameters)
48
- @parameters = parameters
49
- end
50
- deprecated!
51
- end
52
- end
53
-
54
- it 'forwards all parameters to the initializer and returns the original method`s result' do
55
- expect(subject.new(:arg1, :arg2, 42).parameters).to eq([:arg1, :arg2, 42])
56
- end
57
- end
58
-
59
- end
60
-
61
- context 'block forwarding' do
62
-
63
- context 'when an instance method is marked as deprecated' do
64
- subject do
65
- Class.new(BasicObject) do
66
- def foo(arg)
67
- yield(arg)
68
- end
69
- deprecated :foo
70
- end
71
- end
72
-
73
- it 'forwards a given Proc to the original method' do
74
- result = subject.new.foo(41) do |arg|
75
- {my_blocks_result: arg + 1}
76
- end
77
- expect(result).to eq(my_blocks_result: 42)
78
- end
79
- end
80
-
81
- context 'when a class method is marked as deprecated' do
82
- subject do
83
- Class.new(BasicObject) do
84
- def self.foo(arg)
85
- yield(arg)
86
- end
87
- deprecated :foo
88
- end
89
- end
90
-
91
- it 'forwards a given Proc to the original method' do
92
- result = subject.foo(665) do |arg|
93
- {my_blocks_result: arg + 1}
94
- end
95
- expect(result).to eq(my_blocks_result: 666)
96
- end
97
- end
98
-
99
- context 'when a class is marked as deprecated' do
100
- subject do
101
- Class.new(BasicObject) do
102
- attr_reader :value
103
- def initialize(arg)
104
- @value = yield(arg)
105
- end
106
- deprecated!
107
- end
108
- end
109
-
110
- it 'forwards a given Proc to the initializer' do
111
- instance = subject.new(41) do |arg|
112
- {my_blocks_result: arg + 1}
113
- end
114
- expect(instance.value).to eq(my_blocks_result: 42)
115
- end
116
- end
117
-
118
- end
119
-
120
- end
121
-
122
- context 'handling' do
123
-
124
- context 'when a method is marked as deprecated' do
125
-
126
- context 'when an alternative method and a comment are present ' do
127
- subject do
128
- Class.new(BasicObject) do
129
- def foo
130
- end
131
- def bar
132
- end
133
- deprecated :foo, :bar, 'next version'
134
- end
135
- end
136
-
137
- after do
138
- subject.new.foo
139
- end
140
-
141
- it 'calls the handler with correct subject' do
142
- expect(Deprecations).to receive(:call)
143
- .once
144
- .with("#{subject}#foo", anything, anything)
145
- end
146
- it 'calls the handler with correct alternative method' do
147
- expect(Deprecations).to receive(:call)
148
- .once
149
- .with(anything, "#{subject}#bar", anything)
150
- end
151
- it 'calls the handler with a comment' do
152
- expect(Deprecations).to receive(:call)
153
- .once
154
- .with(anything, anything, 'next version')
155
- end
156
- end
157
-
158
- context 'when no alternative method and no comment are present' do
159
- subject do
160
- Class.new(BasicObject) do
161
- def bar
162
- end
163
- deprecated :bar
164
- end
165
- end
166
-
167
- after do
168
- subject.new.bar
169
- end
170
-
171
- it 'calls handler without an alternative method' do
172
- expect(Deprecations).to receive(:call).once.with(anything, nil, anything)
173
- end
174
- it 'calls handler without a comment' do
175
- expect(Deprecations).to receive(:call).once.with(anything, anything, nil)
176
- end
177
- end
178
-
179
- end
180
-
181
- context 'when a class is anonymous defined' do
182
- module Samples
183
- AnonymousDefined = Class.new(::BasicObject) do
184
- def clean; end
185
- def clear; end
186
- deprecated :clean, :clear
187
-
188
- def self.create; end
189
- def self.make; end
190
- deprecated :create, :make
191
- end
192
- end
193
-
194
- it 'uses correct decorated instance method names' do
195
- expect(Deprecations).to receive(:call).once.with(
196
- 'Samples::AnonymousDefined#clean',
197
- 'Samples::AnonymousDefined#clear',
198
- nil
199
- )
200
- Samples::AnonymousDefined.new.clean
201
- end
202
-
203
- it 'uses correct decorated singleton method names' do
204
- expect(Deprecations).to receive(:call).once.with(
205
- 'Samples::AnonymousDefined.create',
206
- 'Samples::AnonymousDefined.make',
207
- nil
208
- )
209
- Samples::AnonymousDefined.create
210
- end
211
- end
212
-
213
- context 'when a sub-class is used' do
214
- module Samples
215
- class Parent < ::BasicObject
216
- def clean; end
217
- def clear; end
218
- deprecated :clean, :clear
219
- end
220
-
221
- class Child < Parent; end
222
- end
223
-
224
- it 'uses correct decorated method names' do
225
- expect(Deprecations).to receive(:call).once.with(
226
- 'Samples::Parent#clean',
227
- 'Samples::Parent#clear',
228
- nil
229
- )
230
- Samples::Child.new.clean
231
- end
232
- end
233
-
234
- end
235
- end
data/spec/spec_helper.rb DELETED
@@ -1,8 +0,0 @@
1
- RSpec.configure do |config|
2
- config.raise_errors_for_deprecations!
3
- config.disable_monkey_patching!
4
- config.expose_dsl_globally = false
5
- config.expect_with(:rspec){ |c| c.syntax = :expect }
6
- config.mock_with(:rspec){ |c| c.syntax = :expect }
7
- end
8
- require 'deprecations'