Sha256: e5de34af9c68bf79e74e9e6791582b4f8415132463c50fa6f0f205d50a83e9fc

Contents?: true

Size: 1.43 KB

Versions: 7

Compression:

Stored size: 1.43 KB

Contents

shared_examples_for "path_extractor" do
    include_examples 'component'

    before( :each ) do
        extractors.namespace.constants.each do |const|
            next if const == :Base
            extractors.namespace.send :remove_const, const
        end
        extractors.clear
    end

    def results
    end

    def text
    end

    def self.easy_test( &block )
        it "extracts the expected paths" do
            raise 'No paths provided via #results, use \':nil\' for \'nil\' results.' if !results

            expect(actual_results.sort).to eq results.sort
            instance_eval &block if block_given?
        end
    end

    def parser
        Arachni::Parser.new(
            Arachni::HTTP::Response.new(
                url:     'http://localhost',
                body:    text,
                headers: {
                    'Content-Type' => 'text/html'
                }
            )
        )
    end

    def actual_results
        results_for( name )
    end

    def results_for( name )
        paths = extractors[name].new( parser: parser, html: text ).run || []
        paths.delete( 'http://www.w3.org/TR/REC-html40/loose.dtd' )
        paths.compact.flatten
    end

    module Arachni::Parser::Extractors
    end
    def extractors
        @path_extractors ||=
            ::Arachni::Component::Manager.new(
                options.paths.path_extractors,
                Arachni::Parser::Extractors
            )
    end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
arachni-1.6.1.3 spec/support/shared/path_extractor.rb
arachni-1.6.1.2 spec/support/shared/path_extractor.rb
arachni-1.6.1.1 spec/support/shared/path_extractor.rb
arachni-1.6.1 spec/support/shared/path_extractor.rb
arachni-1.6.0 spec/support/shared/path_extractor.rb
arachni-1.5.1 spec/support/shared/path_extractor.rb
arachni-1.5 spec/support/shared/path_extractor.rb