From c67421163633439fdee7ac2427bb66e7cd2d3028 Mon Sep 17 00:00:00 2001 From: AI-Mozi Date: Sat, 27 Apr 2024 16:45:18 +0200 Subject: [PATCH] Add example for both input_format and format given --- spec/converter_spec.rb | 13 ++++++++++++- spec/fixtures/converter/input.csv | 3 +++ spec/fixtures/converter/masscan.json | 3 --- 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 spec/fixtures/converter/input.csv delete mode 100644 spec/fixtures/converter/masscan.json diff --git a/spec/converter_spec.rb b/spec/converter_spec.rb index 0546fca..80769df 100644 --- a/spec/converter_spec.rb +++ b/spec/converter_spec.rb @@ -66,7 +66,7 @@ end context 'when format is given' do - it 'must ignore file extension and convert it to given format' do + it 'must ignore file extension and convert it to the given format' do Tempfile.create(tempfile) do |output_file| subject.convert_file(masscan_path, output_file, format: :csv) output_file.rewind @@ -75,6 +75,17 @@ end end end + + context 'when input_format and format are given' do + it 'must set input file format explicitly and convert it to the given format' do + Tempfile.create(tempfile) do |output_file| + subject.convert_file(masscan_path, output_file, input_format: :json, format: :csv) + output_file.rewind + + expect(output_file.read).to eq(expected_csv) + end + end + end end describe '.convert' do diff --git a/spec/fixtures/converter/input.csv b/spec/fixtures/converter/input.csv new file mode 100644 index 0000000..03ccc93 --- /dev/null +++ b/spec/fixtures/converter/input.csv @@ -0,0 +1,3 @@ +type,status.status,status.protocol,status.port,status.reason,status.ttl,status.ip,status.timestamp,banner.protocol,banner.port,banner.ip,banner.timestamp,banner.app_protocol,banner.payload +status,open,tcp,80,"syn,ack",54,93.184.216.34,2021-08-26 08:50:21 +0200 +banner,,,,,,,,tcp,80,93.184.216.34,2021-08-26 08:50:21 +0200,html_title,404 - Not Found diff --git a/spec/fixtures/converter/masscan.json b/spec/fixtures/converter/masscan.json deleted file mode 100644 index cf886f8..0000000 --- a/spec/fixtures/converter/masscan.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - { "ip": "93.184.216.34", "timestamp": "1629960621", "ports": [ {"port": 80, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 54} ] } -]