|
10 | 10 |
|
11 | 11 | let(:ruby_engine) { 'ruby' } |
12 | 12 |
|
| 13 | + def rquote(str) |
| 14 | + Regexp.new(Regexp.quote(str)) |
| 15 | + end |
| 16 | + |
13 | 17 | describe '#show_warnings' do |
14 | 18 | before { subject.show_warnings } |
15 | 19 | context 'when silenced' do |
|
40 | 44 | let(:ruby_version) { '2.2.4' } |
41 | 45 | it 'shows warning about bugs' do |
42 | 46 | expect(STDERR).to have_received(:puts).with( |
43 | | - %r{RubyDep: WARNING: your Ruby is outdated\/buggy.}) |
| 47 | + %r{Your Ruby is outdated\/buggy.}) |
| 48 | + end |
| 49 | + |
| 50 | + it 'shows recommended action' do |
| 51 | + expected = rquote( |
| 52 | + 'Your Ruby is: 2.2.4 (buggy). Recommendation: install'\ |
| 53 | + ' 2.2.5 or 2.3.1') |
| 54 | + expect(STDERR).to have_received(:puts).with(expected) |
44 | 55 | end |
45 | 56 | end |
46 | 57 |
|
47 | 58 | context 'with an insecure Ruby' do |
48 | 59 | let(:ruby_version) { '2.2.3' } |
49 | 60 | it 'shows warning about vulnerability' do |
50 | 61 | expect(STDERR).to have_received(:puts).with( |
51 | | - /RubyDep: WARNING: your Ruby has security vulnerabilities!/) |
| 62 | + /Your Ruby has security vulnerabilities!/) |
| 63 | + end |
| 64 | + |
| 65 | + it 'shows recommended action' do |
| 66 | + expected = rquote( |
| 67 | + 'Your Ruby is: 2.2.3 (insecure). Recommendation:'\ |
| 68 | + ' install 2.2.5 or 2.3.1. (Or, at least to 2.2.4 or 2.3.0)') |
| 69 | + expect(STDERR).to have_received(:puts).with(expected) |
52 | 70 | end |
53 | 71 | end |
54 | 72 |
|
55 | 73 | context 'with an insecure base Ruby' do |
56 | 74 | let(:ruby_version) { '2.2.0' } |
57 | 75 | it 'shows warning about vulnerability' do |
58 | 76 | expect(STDERR).to have_received(:puts).with( |
59 | | - /RubyDep: WARNING: your Ruby has security vulnerabilities!/) |
| 77 | + /Your Ruby has security vulnerabilities!/) |
| 78 | + end |
| 79 | + |
| 80 | + it 'shows recommended action' do |
| 81 | + expected = rquote( |
| 82 | + 'Your Ruby is: 2.2.0 (insecure). Recommendation: install 2.2.5'\ |
| 83 | + ' or 2.3.1. (Or, at least to 2.2.4 or 2.3.0)') |
| 84 | + expect(STDERR).to have_received(:puts).with(expected) |
60 | 85 | end |
61 | 86 | end |
62 | 87 |
|
63 | 88 | context 'with an unsupported Ruby' do |
64 | 89 | let(:ruby_version) { '1.9.3' } |
65 | 90 | it 'shows warning about vulnerability' do |
66 | 91 | expect(STDERR).to have_received(:puts).with( |
67 | | - /RubyDep: WARNING: your Ruby has security vulnerabilities!/) |
| 92 | + /Your Ruby has security vulnerabilities!/) |
| 93 | + end |
| 94 | + |
| 95 | + it 'shows recommended action' do |
| 96 | + expected = rquote( |
| 97 | + 'Your Ruby is: 1.9.3 (insecure). Recommendation: install 2.2.5'\ |
| 98 | + ' or 2.3.1. (Or, at least to 2.1.9 or 2.2.4 or 2.3.0)') |
| 99 | + expect(STDERR).to have_received(:puts).with(expected) |
68 | 100 | end |
69 | 101 | end |
70 | 102 |
|
|
75 | 107 | it 'does not show warning about vulnerability' do |
76 | 108 | expect(STDERR).to_not have_received(:puts) |
77 | 109 | end |
| 110 | + |
| 111 | + it 'does not show a recommendation' do |
| 112 | + expect(STDERR).to_not have_received(:puts).with( |
| 113 | + /RubyDep: Your Ruby is:/) |
| 114 | + expect(STDERR).to_not have_received(:puts).with(/Recommendation:/) |
| 115 | + end |
78 | 116 | end |
79 | 117 | end |
80 | 118 |
|
|
84 | 122 | let(:ruby_engine) { 'ironruby' } |
85 | 123 | it 'shows warning about vulnerability' do |
86 | 124 | expect(STDERR).to have_received(:puts).with( |
87 | | - /RubyDep: WARNING: your Ruby has security vulnerabilities!/) |
| 125 | + /Your Ruby has security vulnerabilities!/) |
| 126 | + end |
| 127 | + |
| 128 | + it 'shows recommended action' do |
| 129 | + expected = rquote( |
| 130 | + "Your Ruby is: 1.2.3 'ironruby' (unrecognized). If this"\ |
| 131 | + ' version is important, please open an issue at'\ |
| 132 | + ' http://github.com/e2/ruby_dep') |
| 133 | + expect(STDERR).to have_received(:puts).with(expected) |
88 | 134 | end |
89 | 135 | end |
90 | 136 | end |
|
0 commit comments