Sha256: 2a0e73d265d363904051ff76d4fcb9c8717bf2c7be1bdf5dc11f0d34da4fd347

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

module CMSScanner
  module Controller
    # Failure class for testing
    class SpecFailure < Base
      def before_scan
        fail 'error spotted'
      end
    end
  end
end

describe CMSScanner::Scan do

  subject(:scanner) { described_class.new }
  let(:controller)  { CMSScanner::Controller }

  describe '#new, #controllers' do
    its(:controllers) { should eq([controller::Core.new]) }
  end

  describe '#run' do
    it 'runs the controlllers and calls the formatter#beautify' do
      expect(scanner.controllers).to receive(:run)
      expect(scanner.formatter).to receive(:beautify)
      scanner.run
    end

    context 'when an error is raised during the #run' do
      it 'aborts the scan with the associated output' do
        scanner.controllers[0] = controller::SpecFailure.new

        expect(scanner.formatter).to receive(:output)
          .with('@scan_aborted', hash_including(:reason, :trace, :verbose))

        scanner.run
      end
    end
  end

  describe '#datastore' do
    its(:datastore) { should eq({}) }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cms_scanner-0.0.5 spec/lib/cms_scanner_spec.rb
cms_scanner-0.0.4 spec/lib/cms_scanner_spec.rb
cms_scanner-0.0.3 spec/lib/cms_scanner_spec.rb
cms_scanner-0.0.2 spec/lib/cms_scanner_spec.rb