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

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

View File

@ -117,7 +117,7 @@ describe Msf::Ui::Console::CommandDispatcher::Core do
mod
end
it "should show an empty value if not set in the framework or module" do
it "should show no 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)
@ -154,4 +154,60 @@ describe Msf::Ui::Console::CommandDispatcher::Core do
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 /
end
end
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 no 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_getg(name)
@output.join.should =~ /^#{name} => $/
end
it "should show no 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_getg(name)
@output.join.should =~ /^#{name} => $/
end
it "should show the framework's 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_getg(name)
@output.join.should =~ /^#{name} => FRAMEWORK$/
end
it "should show the framework'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_getg(name)
@output.join.should =~ /^#{name} => FRAMEWORK$/
end
end
end
end
end