|
6 | 6 | stub_const('RUBY_VERSION', ruby_version) |
7 | 7 | end |
8 | 8 |
|
9 | | - context 'with an up-to-date Ruby' do |
10 | | - let(:ruby_version) { '2.3.1' } |
11 | | - it '#show_warnings' do |
12 | | - expect(STDERR).to_not receive(:puts) |
13 | | - subject.show_warnings |
14 | | - end |
15 | | - end |
| 9 | + describe '#show_warnings' do |
| 10 | + context 'when silenced' do |
| 11 | + around do |example| |
| 12 | + old = ENV['RUBY_DEP_GEM_SILENCE_WARNINGS'] |
| 13 | + ENV['RUBY_DEP_GEM_SILENCE_WARNINGS'] = '1' |
| 14 | + example.run |
| 15 | + ENV['RUBY_DEP_GEM_SILENCE_WARNINGS'] = old |
| 16 | + end |
16 | 17 |
|
17 | | - context 'with a secure but buggy Ruby' do |
18 | | - let(:ruby_version) { '2.2.4' } |
19 | | - it '#show_warnings' do |
20 | | - expect(STDERR).to receive(:puts).with( |
21 | | - 'RubyDep: WARNING: your Ruby is outdated/buggy. Please upgrade.') |
22 | | - subject.show_warnings |
| 18 | + context 'with any outdated Ruby' do |
| 19 | + let(:ruby_version) { '1.9.3' } |
| 20 | + it 'does not show warning' do |
| 21 | + expect(STDERR).to_not receive(:puts) |
| 22 | + subject.show_warnings |
| 23 | + end |
| 24 | + end |
23 | 25 | end |
24 | | - end |
25 | 26 |
|
26 | | - context 'with an insecure Ruby' do |
27 | | - let(:ruby_version) { '2.2.3' } |
28 | | - it '#show_warnings' do |
29 | | - expect(STDERR).to receive(:puts).with( |
30 | | - 'RubyDep: WARNING: your Ruby has security vulnerabilities!'\ |
31 | | - ' Please upgrade!') |
32 | | - subject.show_warnings |
33 | | - end |
34 | | - end |
| 27 | + context 'when not silenced' do |
| 28 | + context 'with an up-to-date Ruby' do |
| 29 | + let(:ruby_version) { '2.3.1' } |
| 30 | + it 'does not show warning' do |
| 31 | + expect(STDERR).to_not receive(:puts) |
| 32 | + subject.show_warnings |
| 33 | + end |
| 34 | + end |
| 35 | + |
| 36 | + context 'with a secure but buggy Ruby' do |
| 37 | + let(:ruby_version) { '2.2.4' } |
| 38 | + it 'shows warning about bugs' do |
| 39 | + expect(STDERR).to receive(:puts).with( |
| 40 | + %r{RubyDep: WARNING: your Ruby is outdated\/buggy.}) |
| 41 | + subject.show_warnings |
| 42 | + end |
| 43 | + end |
| 44 | + |
| 45 | + context 'with an insecure Ruby' do |
| 46 | + let(:ruby_version) { '2.2.3' } |
| 47 | + it 'shows warning about vulnerability' do |
| 48 | + expect(STDERR).to receive(:puts).with( |
| 49 | + /RubyDep: WARNING: your Ruby has security vulnerabilities!/) |
| 50 | + subject.show_warnings |
| 51 | + end |
| 52 | + end |
35 | 53 |
|
36 | | - context 'with an unsupported Ruby' do |
37 | | - let(:ruby_version) { '1.9.3' } |
38 | | - it '#show_warnings' do |
39 | | - expect(STDERR).to receive(:puts).with( |
40 | | - 'RubyDep: WARNING: your Ruby has security vulnerabilities!'\ |
41 | | - ' Please upgrade!') |
42 | | - subject.show_warnings |
| 54 | + context 'with an unsupported Ruby' do |
| 55 | + let(:ruby_version) { '1.9.3' } |
| 56 | + it 'shows warning about vulnerability' do |
| 57 | + expect(STDERR).to receive(:puts).with( |
| 58 | + /RubyDep: WARNING: your Ruby has security vulnerabilities!/) |
| 59 | + subject.show_warnings |
| 60 | + end |
| 61 | + end |
43 | 62 | end |
44 | 63 | end |
45 | 64 | end |
0 commit comments