|
106 | 106 |
|
107 | 107 | context 'when the db is outdated' do
|
108 | 108 | before do
|
109 |
| - allow(core).to receive(:user_interaction?).and_return(true) |
110 | 109 | expect(core.local_db).to receive(:outdated?).ordered.and_return(true)
|
111 | 110 | expect(core.formatter).to receive(:output).with('@notice', hash_including(:msg), 'core').ordered
|
| 111 | + expect($stdout).to receive(:write).ordered # for the print() |
112 | 112 | end
|
113 | 113 |
|
114 | 114 | context 'when a positive answer' do
|
115 |
| - before do |
116 |
| - expect(Readline).to receive(:readline).with('[?] Do you want to update now? [Y]es [N]o, default: [N] ', |
117 |
| - true).and_return('Yes') |
118 |
| - end |
| 115 | + before { expect(Readline).to receive(:readline).and_return('Yes').ordered } |
119 | 116 |
|
120 | 117 | its(:update_db_required?) { should eql true }
|
121 | 118 | end
|
122 | 119 |
|
123 | 120 | context 'when a negative answer' do
|
124 |
| - before do |
125 |
| - expect(Readline).to receive(:readline).with('[?] Do you want to update now? [Y]es [N]o, default: [N] ', |
126 |
| - true).and_return('No') |
127 |
| - end |
| 121 | + before { expect(Readline).to receive(:readline).and_return('no').ordered } |
128 | 122 |
|
129 | 123 | its(:update_db_required?) { should eql false }
|
130 | 124 | end
|
|
151 | 145 | context 'when --update' do
|
152 | 146 | before do
|
153 | 147 | expect(core.formatter).to receive(:output)
|
154 |
| - .with('db_update_started', hash_including(verbose: nil), 'core').ordered |
| 148 | + .with('db_update_started', hash_including(verbose: nil), 'core').ordered |
155 | 149 |
|
156 | 150 | expect_any_instance_of(WPScan::DB::Updater).to receive(:update)
|
157 | 151 |
|
158 | 152 | expect(core.formatter).to receive(:output)
|
159 |
| - .with('db_update_finished', hash_including(verbose: nil), 'core').ordered |
| 153 | + .with('db_update_finished', hash_including(verbose: nil), 'core').ordered |
160 | 154 | end
|
161 | 155 |
|
162 | 156 | context 'when the --url is not supplied' do
|
|
200 | 194 | stub_request(:any, target_url)
|
201 | 195 |
|
202 | 196 | expect(core.target).to receive(:homepage_res)
|
203 |
| - .at_least(1) |
204 |
| - .and_return(Typhoeus::Response.new(effective_url: redirection, body: '')) |
| 197 | + .at_least(1) |
| 198 | + .and_return(Typhoeus::Response.new(effective_url: redirection, body: '')) |
205 | 199 | end
|
206 | 200 |
|
207 | 201 | context 'to the wp-admin/install.php' do
|
208 | 202 | let(:redirection) { "#{target_url}wp-admin/install.php" }
|
209 | 203 |
|
210 | 204 | it 'calls the formatter with the correct parameters and exit' do
|
211 | 205 | expect(core.formatter).to receive(:output)
|
212 |
| - .with('not_fully_configured', hash_including(url: redirection), 'core').ordered |
| 206 | + .with('not_fully_configured', hash_including(url: redirection), 'core').ordered |
213 | 207 |
|
214 | 208 | # TODO: Would be cool to be able to test the exit code
|
215 | 209 | expect { core.before_scan }.to raise_error(SystemExit)
|
|
0 commit comments