diff options
author | Chris Doherty <cdoherty@chef.io> | 2016-02-29 12:37:24 -0800 |
---|---|---|
committer | Chris Doherty <cdoherty@chef.io> | 2016-03-17 14:56:02 -0700 |
commit | 81276da7a221ca1a935b069608580839e94b7154 (patch) | |
tree | 446afd35fb51bfc959c0825f3ea41f5e5776313d | |
parent | fda49f6f8133fbb6f389f1def8e0aad4856614b7 (diff) | |
download | chef-81276da7a221ca1a935b069608580839e94b7154.tar.gz |
Rubocop.
-rw-r--r-- | chef-config/lib/chef-config/config.rb | 16 | ||||
-rw-r--r-- | chef-config/spec/unit/config_spec.rb | 3 | ||||
-rw-r--r-- | spec/unit/rest/auth_credentials_spec.rb | 8 |
3 files changed, 13 insertions, 14 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb index c3d330ef77..9da69a1867 100644 --- a/chef-config/lib/chef-config/config.rb +++ b/chef-config/lib/chef-config/config.rb @@ -856,14 +856,14 @@ module ChefConfig # proxy before parsing. The regex /^.*:\/\// matches, for example, http://. Reusing proxy # here since we are really just trying to get the string built correctly. proxy = if !proxy_env_var.empty? - if proxy_env_var.match(/^.*:\/\//) - URI.parse(proxy_env_var) - else - URI.parse("#{scheme}://#{proxy_env_var}") - end - end - - excludes = ENV['no_proxy'].to_s.split(/\s*,\s*/).compact + if proxy_env_var =~ /^.*:\/\// + URI.parse(proxy_env_var) + else + URI.parse("#{scheme}://#{proxy_env_var}") + end + end + + excludes = ENV["no_proxy"].to_s.split(/\s*,\s*/).compact excludes = excludes.map { |exclude| exclude =~ /:\d+$/ ? exclude : "#{exclude}:*" } return proxy unless excludes.any? { |exclude| File.fnmatch(exclude, "#{host}:#{port}") } end diff --git a/chef-config/spec/unit/config_spec.rb b/chef-config/spec/unit/config_spec.rb index 1e28f5b3e4..3bada755de 100644 --- a/chef-config/spec/unit/config_spec.rb +++ b/chef-config/spec/unit/config_spec.rb @@ -855,7 +855,7 @@ RSpec.describe ChefConfig::Config do context "when an empty proxy is set by the environment" do let(:env) do { - "https_proxy" => "" + "https_proxy" => "", } end @@ -887,7 +887,6 @@ RSpec.describe ChefConfig::Config do it { is_expected.to eq nil } end - context "when no_proxy is included on a list" do let(:env) do { diff --git a/spec/unit/rest/auth_credentials_spec.rb b/spec/unit/rest/auth_credentials_spec.rb index af6fc01aeb..dcc0f923b4 100644 --- a/spec/unit/rest/auth_credentials_spec.rb +++ b/spec/unit/rest/auth_credentials_spec.rb @@ -96,13 +96,13 @@ end describe Chef::REST::RESTRequest do let(:url) { URI.parse("http://chef.example.com:4000/?q=chef_is_awesome") } - def new_request(method=nil) + def new_request(method = nil) method ||= :POST Chef::REST::RESTRequest.new(method, url, @req_body, @headers) end before do - @auth_credentials = Chef::REST::AuthCredentials.new("client-name", CHEF_SPEC_DATA + '/ssl/private_key.pem') + @auth_credentials = Chef::REST::AuthCredentials.new("client-name", CHEF_SPEC_DATA + "/ssl/private_key.pem") @req_body = '{"json_data":"as_a_string"}' @headers = { "Content-type" => "application/json", "Accept" => "application/json", @@ -182,7 +182,7 @@ describe Chef::REST::RESTRequest do "http_proxy_pass" => nil, "https_proxy_user" => nil, "https_proxy_pass" => nil, - "no_proxy" => nil, + "no_proxy" => nil ) end @@ -265,7 +265,7 @@ describe Chef::REST::RESTRequest do describe "with :https_proxy_user and :https_proxy_pass set" do before do stub_const("ENV", "http_proxy" => "http://proxy.example.com:3128", - "https_proxy" => "https://homie:theclown@sproxy.example.com:3129", + "https_proxy" => "https://homie:theclown@sproxy.example.com:3129" ) end |