-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdeprecation_spec.rb
41 lines (34 loc) · 1.22 KB
/
deprecation_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# frozen_string_literal: true
RSpec.describe Faulty::Deprecation do
it 'prints note and sunset version' do
expect(Kernel).to receive(:warn)
.with('DEPRECATION: foo is deprecated and will be removed in 1.0 (Use bar)')
described_class.deprecate(:foo, note: 'Use bar', sunset: '1.0')
end
it 'prints only subject' do
expect(Kernel).to receive(:warn)
.with('DEPRECATION: blah is deprecated')
described_class.deprecate('blah')
end
it 'prints method deprecation' do
expect(Kernel).to receive(:warn)
.with('DEPRECATION: Faulty::Circuit#foo is deprecated and will be removed in 1.0 (Use bar)')
described_class.method(Faulty::Circuit, :foo, note: 'Use bar', sunset: '1.0')
end
context 'with raise_errors!' do
before { described_class.raise_errors! }
after { described_class.raise_errors!(false) }
it 'raises DeprecationError' do
expect { described_class.deprecate('blah') }
.to raise_error(Faulty::DeprecationError, 'blah is deprecated')
end
end
context 'when silenced' do
it 'does not surface deprecations' do
expect(Kernel).not_to receive(:warn)
described_class.silenced do
described_class.deprecate('blah')
end
end
end
end