Sha256: fa8dda3a49e4d680e63ba595d12a87a48c32d18f7d65fae7d3fefff4d0ad66fc

Contents?: true

Size: 960 Bytes

Versions: 17

Compression:

Stored size: 960 Bytes

Contents

# frozen_string_literal: true

require 'aranha/parsers/source_address'
require 'eac_envs/http/rspec/echo_server'
require 'eac_ruby_utils/yaml'

::RSpec.describe ::Aranha::Parsers::SourceAddress do
  describe '#detect_sub' do
    let(:http_server) { ::EacEnvs::Http::Rspec::EchoServer.http }

    around { |example| http_server.on_active(&example) }

    include_examples 'source_target_fixtures', __FILE__

    def source_data(source_file)
      source = ::EacRubyUtils::Yaml.load_file(source_file)
      url = source_url_get(source)
      %w[scheme host port].each { |attr| url.send("#{attr}=", http_server.root_url.send(attr)) }
      if source.is_a?(::Hash)
        source[:url] = url.to_s
      else
        source = url.to_s
      end
      ::JSON.parse(described_class.detect_sub(source).content)
    end

    # @return [Addressable::URI]
    def source_url_get(source)
      (source.is_a?(::Hash) ? source.fetch(:url) : source).to_uri
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
eac_tools-0.69.1 sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb
eac_tools-0.69.0 sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb
eac_tools-0.68.0 sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb
eac_tools-0.67.1 sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb
eac_tools-0.67.0 sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb
eac_tools-0.66.0 sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb
eac_tools-0.65.1 sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb
eac_tools-0.65.0 sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb
eac_tools-0.64.0 sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb
eac_tools-0.63.0 sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb
eac_tools-0.62.1 sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb
eac_tools-0.62.0 sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb
eac_tools-0.61.1 sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb
eac_tools-0.61.0 sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb
eac_tools-0.60.3 sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb
eac_tools-0.60.2 sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb
eac_tools-0.60.1 sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb