2015-11-20 23:18:14 +00:00
|
|
|
require 'rex/parser/ini'
|
|
|
|
|
2016-01-29 17:31:40 +00:00
|
|
|
RSpec.describe Rex::Parser::Ini do
|
2015-11-20 23:18:14 +00:00
|
|
|
let(:ini_contents) { <<EOF
|
|
|
|
# global comment
|
|
|
|
global settting = blah
|
|
|
|
[foo]
|
|
|
|
a = b
|
|
|
|
[bar]
|
|
|
|
b = c
|
|
|
|
|
|
|
|
[baf]
|
|
|
|
c = d
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
let(:ini) { described_class.from_s(ini_contents) }
|
|
|
|
|
|
|
|
context "#each_group" do
|
|
|
|
it "enumerates the groups" do
|
|
|
|
groups = []
|
|
|
|
ini.each_group { |group| groups << group }
|
|
|
|
groups.should eq(%w(foo bar baf))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "#each_key" do
|
|
|
|
it "enumerates the groups" do
|
|
|
|
groups = []
|
|
|
|
ini.each_key.map { |group| groups << group }
|
|
|
|
groups.should eq(%w(foo bar baf))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|