1deacad2be
Came up on Twitter, where Justin may have been trolling a little: https://twitter.com/jstnkndy/status/798671298302017536 We have a `print_good` method, but not a `print_bad`, which seems a little weird for Ruby -- opposite methods should be intuitive as Justin is implying. Anyway, I went with alias_method, thanks to the compelling argument at https://github.com/bbatsov/ruby-style-guide#alias-method ...since Metasploit is all about the singleton, and didn't want to risk some unexpected scoping thing. Also dang, we define the `print_` methods like fifty billion times! Really should fix that some day.
27 lines
833 B
Ruby
27 lines
833 B
Ruby
RSpec.shared_context 'Msf::UIDriver' do
|
|
let(:driver) do
|
|
double(
|
|
'Driver',
|
|
:framework => framework
|
|
).tap { |driver|
|
|
allow(driver).to receive(:on_command_proc=).with(kind_of(Proc))
|
|
allow(driver).to receive(:print_line).with(kind_of(String)) do |string|
|
|
@output ||= []
|
|
@output.concat string.split("\n")
|
|
end
|
|
allow(driver).to receive(:print_status).with(kind_of(String)) do |string|
|
|
@output ||= []
|
|
@output.concat string.split("\n")
|
|
end
|
|
allow(driver).to receive(:print_error).with(kind_of(String)) do |string|
|
|
@error ||= []
|
|
@error.concat string.split("\n")
|
|
end
|
|
allow(driver).to receive(:print_bad).with(kind_of(String)) do |string|
|
|
@error ||= []
|
|
@error.concat string.split("\n")
|
|
end
|
|
}
|
|
end
|
|
end
|