Skip to content

Commit e298c5b

Browse files
committed
Add a simple spec for DataStore
1 parent cf93a81 commit e298c5b

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

spec/lib/msf/core/data_store_spec.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
require 'spec_helper'
3+
require 'msf/core/data_store'
4+
5+
shared_examples "datastore" do
6+
it "should have options" do
7+
subject["foo"].should == "bar"
8+
subject["fizz"].should == "buzz"
9+
end
10+
it "should have case-insensitive keys" do
11+
# Sorted by gray code, just for fun
12+
subject["foo"].should == "bar"
13+
subject["Foo"].should == "bar"
14+
subject["FOo"].should == "bar"
15+
subject["fOo"].should == "bar"
16+
subject["fOO"].should == "bar"
17+
subject["FOO"].should == "bar"
18+
subject["FoO"].should == "bar"
19+
subject["foO"].should == "bar"
20+
end
21+
end
22+
23+
describe Msf::DataStore do
24+
25+
describe "#import_options_from_hash" do
26+
subject do
27+
hash = { "foo" => "bar", "fizz" => "buzz" }
28+
s = described_class.new
29+
s.import_options_from_hash(hash)
30+
s
31+
end
32+
it_behaves_like "datastore"
33+
end
34+
35+
describe "#import_options_from_s" do
36+
subject do
37+
str = "foo=bar fizz=buzz"
38+
s = described_class.new
39+
s.import_options_from_s(str)
40+
s
41+
end
42+
it_behaves_like "datastore"
43+
end
44+
45+
end

0 commit comments

Comments
 (0)