diff --git a/kitchen-ec2.gemspec b/kitchen-ec2.gemspec index 28cb6100..5704bc94 100644 --- a/kitchen-ec2.gemspec +++ b/kitchen-ec2.gemspec @@ -1,6 +1,6 @@ -lib = File.expand_path("../lib", __FILE__) +lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "kitchen/driver/ec2_version.rb" +require "kitchen/driver/ec2_version" Gem::Specification.new do |gem| gem.name = "kitchen-ec2" diff --git a/lib/kitchen/driver/aws/instance_generator.rb b/lib/kitchen/driver/aws/instance_generator.rb index 58c72464..2b6841a6 100644 --- a/lib/kitchen/driver/aws/instance_generator.rb +++ b/lib/kitchen/driver/aws/instance_generator.rb @@ -58,7 +58,7 @@ def ec2_instance_data # rubocop:disable Metrics/MethodLength, Metrics/AbcSize raise "The subnet tagged '#{config[:subnet_filter][:tag]}:#{config[:subnet_filter][:value]}' does not exist!" unless subnets.any? # => Select the least-populated subnet if we have multiple matches - subnet = subnets.sort_by { |s| s[:available_ip_address_count] }.last + subnet = subnets.max_by { |s| s[:available_ip_address_count] } vpc_id = subnet.vpc_id config[:subnet_id] = subnet.subnet_id end