Skip to content

Commit

Permalink
Add a Ronin::Recon::Config#save method
Browse files Browse the repository at this point in the history
  • Loading branch information
AI-Mozi committed Aug 19, 2024
1 parent aa83557 commit 0e24b72
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/ronin/recon/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions spec/config_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

0 comments on commit 0e24b72

Please sign in to comment.