Skip to content

Commit 2cbc15a

Browse files
committed
Add #import_option and #from_file
1 parent e298c5b commit 2cbc15a

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

spec/lib/msf/core/data_store_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,25 @@
1818
subject["FoO"].should == "bar"
1919
subject["foO"].should == "bar"
2020
end
21+
context "#to_h" do
22+
it "should return a Hash with correct values" do
23+
subject.to_h.should == { "foo" => "bar", "fizz" => "buzz" }
24+
end
25+
end
2126
end
2227

2328
describe Msf::DataStore do
2429

30+
describe "#import_option" do
31+
subject do
32+
s = described_class.new
33+
s.import_option("foo", "bar")
34+
s.import_option("fizz", "buzz")
35+
s
36+
end
37+
it_behaves_like "datastore"
38+
end
39+
2540
describe "#import_options_from_hash" do
2641
subject do
2742
hash = { "foo" => "bar", "fizz" => "buzz" }
@@ -42,4 +57,22 @@
4257
it_behaves_like "datastore"
4358
end
4459

60+
describe "#from_file" do
61+
subject do
62+
ini_instance = double
63+
ini_instance.stub(:group?).and_return(true)
64+
ini_instance.stub(:[]).and_return( { "foo" => "bar", "fizz" => "buzz" } )
65+
66+
ini = stub_const("Rex::Parser::Ini", Class.new)
67+
ini.stub(:from_file).and_return(ini_instance)
68+
69+
s = described_class.new
70+
s.from_file("path")
71+
s
72+
end
73+
74+
it_behaves_like "datastore"
75+
end
76+
77+
4578
end

0 commit comments

Comments
 (0)