Skip to content

Commit

Permalink
Add a Ronin::Recon::Config#save method (#162)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Postmodern <[email protected]>
  • Loading branch information
AI-Mozi and postmodern authored Sep 1, 2024
1 parent d862526 commit e979195
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/ronin/recon/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,18 @@ def to_yaml(options={})
data.to_yaml(options)
end

#
# Writes config converted to YAML into a file.
#
# @param [String] path
# The output file path.
#
# @since 0.2.0
#
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 @@ -855,4 +857,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 e979195

Please sign in to comment.