Skip to content

Commit da1c56a

Browse files
committed
Add minimal tests for get/getg
1 parent ba2c331 commit da1c56a

File tree

2 files changed

+27
-6
lines changed
  • lib/msf/ui/console/command_dispatcher
  • spec/lib/msf/ui/console/command_dispatcher

2 files changed

+27
-6
lines changed

lib/msf/ui/console/command_dispatcher/core.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,19 +2317,19 @@ def cmd_get(*args)
23172317
global = true
23182318
end
23192319

2320+
# No arguments? No cookie.
2321+
if args.empty?
2322+
global ? cmd_getg_help : cmd_get_help
2323+
return false
2324+
end
2325+
23202326
# Determine which data store we're operating on
23212327
if (active_module && !global)
23222328
datastore = active_module.datastore
23232329
else
23242330
datastore = framework.datastore
23252331
end
23262332

2327-
# No arguments? No cookie.
2328-
if args.empty?
2329-
global ? cmd_getg_help : cmd_get_help
2330-
return false
2331-
end
2332-
23332333
args.each { |var| print_line("#{var} => #{datastore[var]}") }
23342334
end
23352335

spec/lib/msf/ui/console/command_dispatcher/core_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,25 @@ def cell(table, row, column)
9595
end
9696
end
9797
end
98+
99+
it { is_expected.to respond_to :cmd_get }
100+
it { is_expected.to respond_to :cmd_getg }
101+
102+
describe "#cmd_get" do
103+
describe "without arguments" do
104+
it "should show a help message" do
105+
core.cmd_get
106+
@output.join.should =~ /Usage: get /
107+
end
108+
end
109+
end
110+
111+
describe "#cmd_getg" do
112+
describe "without arguments" do
113+
it "should show a help message" do
114+
core.cmd_getg
115+
@output.join.should =~ /Usage: getg /
116+
end
117+
end
118+
end
98119
end

0 commit comments

Comments
 (0)