Add rspec coverage for get (and set/setg, in a way)

bug/bundler_fix
Jon Hart 2015-01-16 08:28:32 -08:00
parent da1c56a65d
commit 7f90b68cce
No known key found for this signature in database
GPG Key ID: 2FA9F0A3AFA8E9D3
1 changed files with 44 additions and 6 deletions

View File

@ -106,13 +106,51 @@ describe Msf::Ui::Console::CommandDispatcher::Core do
@output.join.should =~ /Usage: get /
end
end
end
describe "#cmd_getg" do
describe "without arguments" do
it "should show a help message" do
core.cmd_getg
@output.join.should =~ /Usage: getg /
describe "with arguments" do
let(:name) { ::Rex::Text.rand_text_alpha(10).upcase }
context "with an active module" do
let(:mod) do
mod = ::Msf::Module.new
mod.send(:initialize, {})
mod
end
it "should show an empty value if not set in the framework or module" do
allow(core).to receive(:active_module).and_return(mod)
allow(driver).to receive(:on_variable_set).and_return(true)
core.cmd_get(name)
@output.join.should =~ /^#{name} => $/
end
it "should show no value when only the framework has this variable" do
allow(core).to receive(:active_module).and_return(mod)
allow(driver).to receive(:on_variable_set).and_return(true)
core.cmd_setg(name, 'FRAMEWORK')
@output = []
core.cmd_get(name)
@output.join.should =~ /^#{name} => $/
end
it "should show the module's value when only the module has this variable" do
allow(core).to receive(:active_module).and_return(mod)
allow(driver).to receive(:on_variable_set).and_return(true)
core.cmd_set(name, 'MODULE')
@output = []
core.cmd_get(name)
@output.join.should =~ /^#{name} => MODULE$/
end
it "should show the module's value when both the module and the framework have this variable" do
allow(core).to receive(:active_module).and_return(mod)
allow(driver).to receive(:on_variable_set).and_return(true)
core.cmd_setg(name, 'FRAMEWORK')
core.cmd_set(name, 'MODULE')
@output = []
core.cmd_get(name)
@output.join.should =~ /^#{name} => MODULE$/
end
end
end
end