diff --git a/lib/ronin/recon/config.rb b/lib/ronin/recon/config.rb index cd2ce79..92eabcd 100644 --- a/lib/ronin/recon/config.rb +++ b/lib/ronin/recon/config.rb @@ -380,6 +380,16 @@ def to_yaml res.to_yaml end + + # + # Writes config converted to YAML into a file. + # + # @param [String] path + # The output file path. + # + def save(path=DEFAULT_PATH) + File.write(path,to_yaml) + end end end end diff --git a/spec/config_spec.rb b/spec/config_spec.rb index fdf529c..67aa14f 100644 --- a/spec/config_spec.rb +++ b/spec/config_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' require 'ronin/recon/config' +require 'tmpdir' + describe Ronin::Recon::Config do describe described_class::Workers do describe "#initialize" do @@ -768,4 +770,17 @@ expect(subject.to_yaml).to eq(File.read(expected_yml)) end end + + describe "#save" do + subject { described_class.default } + + let(:tempdir) { Dir.mktmpdir('test-ronin-recon-config-save') } + let(:path) { File.join(tempdir, 'test-config.yml') } + + it "must write Config converted to YAML into a file" do + subject.save(path) + + expect(File.read(path)).to eq(subject.to_yaml) + end + end end