Sha256: 41f68f22928855bbdc97da5c114a2a5e7c190be5df3c2cc345ba0a14f42f0c35
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
require 'spec_helper' require 'feed_file_examples' require 'nvd/json_feeds/zip_feed_file' require 'fileutils' require 'shellwords' describe NVD::JSONFeeds::ZipFeedFile do let(:fixtures_dir) { File.expand_path('../fixtures',__FILE__) } let(:json_filename) { 'nvdcve-1.1-recent.json' } let(:json_file) { File.join(fixtures_dir,json_filename) } let(:zip_filename) { "#{json_filename}.zip" } let(:dir) { File.join(fixtures_dir,'zip_feed_file') } let(:path) { File.join(dir,zip_filename) } subject { described_class.new(path) } include_examples "FeedFile" describe "#json_filename" do it "must return the '.json' filename without the '.zip' extension" do expect(subject.json_filename).to eq(json_filename) end end describe "#read" do it "must read the unziped contents" do expect(subject.read).to be == File.read(json_file) end context "when unzip is not installed" do before do expect(subject).to receive(:`).and_raise(Errno::ENOENT) end it do expect { subject.read }.to raise_error(ReadFailed) end end end describe "#extract" do let(:extracted_json_file) { File.join(dir,json_filename) } it "must unzip the '.zip' file and return a JSONFeedfile" do feed_file = subject.extract expect(feed_file).to be_kind_of(JSONFeedFile) expect(feed_file.path).to eq(extracted_json_file) expect(File.file?(extracted_json_file)).to be(true) end context "when unzip fails" do before do allow(subject).to receive(:system).and_return(false) end it do expect { subject.extract }.to raise_error(ExtractFailed) end end after { FileUtils.rm_f(extracted_json_file) } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nvd-json_feeds-0.1.0 | spec/zip_feed_file_spec.rb |