Sha256: 77536e375cbdcc7bbf073903ed638ba345ba93a74f642f69fdf1e248afa53cfd

Contents?: true

Size: 998 Bytes

Versions: 13

Compression:

Stored size: 998 Bytes

Contents

# frozen_string_literal: true

RSpec::Matchers.define :have_route do |destination|
  match do |route_table|
    if !is_ipaddr?(destination) && @use_destination # for deprecated usage
      @gateway_id = destination
    else
      @destination = destination
    end
    route_table.has_route?(@destination, @gateway_id, @instance_id, @vpc_peering_connection_id, @nat_gateway_id)
  end

  chain :target do |target|
    @gateway_id = target[:gateway]
    @instance_id = target[:instance]
    @vpc_peering_connection_id = target[:vpc_peering_connection]
    @nat_gateway_id = target[:nat]
  end

  chain :destination do |dest|
    # rubocop:disable Layout/LineLength
    puts ''
    warn Color.on_red(Color.white('!!! route_table destination is deprecated. see https://github.com/k1LoW/awspec/pull/65 !!!'))
    # rubocop:enable Layout/LineLength
    @use_destination = true
    @destination = dest
  end

  private

  def is_ipaddr?(str)
    IPAddr.new(str)
  rescue StandardError
    false
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
awspec-1.31.0 lib/awspec/matcher/have_route.rb
awspec-1.30.0 lib/awspec/matcher/have_route.rb
awspec-1.29.3 lib/awspec/matcher/have_route.rb
awspec-1.29.2 lib/awspec/matcher/have_route.rb
awspec-1.29.1 lib/awspec/matcher/have_route.rb
awspec-1.29.0 lib/awspec/matcher/have_route.rb
awspec-1.28.2 lib/awspec/matcher/have_route.rb
awspec-1.28.1 lib/awspec/matcher/have_route.rb
awspec-1.28.0 lib/awspec/matcher/have_route.rb
awspec-1.27.1 lib/awspec/matcher/have_route.rb
awspec-1.27.0 lib/awspec/matcher/have_route.rb
awspec-1.26.0 lib/awspec/matcher/have_route.rb
awspec-1.25.2 lib/awspec/matcher/have_route.rb