spec/upload_spec.rb in dradis-nipper-3.19.0 vs spec/upload_spec.rb in dradis-nipper-3.20.0

- old
+ new

@@ -1,6 +1,6 @@ -require 'spec_helper' +require 'rails_helper' describe 'Nipper upload plugin' do describe 'importer' do before(:each) do # Stub template service @@ -21,26 +21,34 @@ expect(@content_service).to receive(:create_note) do |args| expect(args[:text]).to include('No reports were detected in the uploaded file (/report).') OpenStruct.new(args) end.once - @importer.import(file: 'spec/fixtures/files/invalid.xml') + @importer.import(file: File.expand_path('../spec/fixtures/files/invalid.xml', __dir__)) end it 'creates nodes, issues, and evidences as needed' do expect(@content_service).to receive(:create_node) do |args| expect(args[:label]).to eq('PA-200') expect(args[:type]).to eq(:host) - OpenStruct.new(args) + @node = Node.create(label: args[:label]) end.once expect(@content_service).to receive(:create_issue) do |args| OpenStruct.new(args) end.exactly(2).times expect(@content_service).to receive(:create_evidence) do |args| OpenStruct.new(args) end.exactly(2).times # Run the import - @importer.import(file: 'spec/fixtures/files/sample.xml') + @importer.import(file: File.expand_path('../spec/fixtures/files/sample.xml', __dir__)) + + expect(@node.properties).to eq( + { + 'device_name'=>'PA-200', + 'device_type'=>'Palo Alto Firewall', + 'os_version'=>'7.0.0' + } + ) end end end