diff --git a/.rubocop.yml b/.rubocop.yml index 0798cf7..5f3dda8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,5 @@ AllCops: + TargetRubyVersion: 2.4+ DisplayCopNames: true Exclude: - 'db/**/*.rb' @@ -33,6 +34,10 @@ Style/Documentation: Layout/LineLength: Enabled: false +Metrics/BlockLength: + Max: 50 + IgnoredMethods: ['describe', 'context'] + Metrics/MethodLength: Enabled: false @@ -92,6 +97,9 @@ Style/GuardClause: Exclude: - 'spec/support/remote_ip_monkey_patch.rb' +Lint/DuplicateMethods: + Enabled: false + # Offense count: 2 Lint/ShadowingOuterLocalVariable: Exclude: diff --git a/spec/sony_ci_api/client_spec.rb b/spec/sony_ci_api/client_spec.rb index f8a2d2a..eae4663 100644 --- a/spec/sony_ci_api/client_spec.rb +++ b/spec/sony_ci_api/client_spec.rb @@ -19,6 +19,20 @@ def stub_request_and_call_block(http_method, path, with: {}, stub_response: {}) return_val end +# Create some dummy class available in a global scope that can be +# recognized by ERB within SonyCiApi::Client#load_config! +class TestCredentials + def self.config_hash + @config_hash ||= { + username: rand(9999).to_s, + password: rand(9999).to_s, + workspace_id: rand(9999).to_s, + client_id: rand(9999).to_s, + client_secret: rand(9999).to_s + } + end +end + RSpec.describe SonyCiApi::Client do def randhex(len = 32) len.times.map { rand(15).to_s(16) }.join @@ -530,20 +544,6 @@ def camelize_params(**params) valid_config_file.write(config_hash.to_yaml) && valid_config_file.rewind valid_config_file_erb.write(config_hash_with_erb.to_yaml) && valid_config_file_erb.rewind invalid_config_file.write(':') && invalid_config_file.rewind - - # Create some dummy class available in a global scope that can be - # recognized by ERB within SonyCiApi::Client#load_config! - class TestCredentials - def self.config_hash - @config_hash ||= { - username: rand(9999).to_s, - password: rand(9999).to_s, - workspace_id: rand(9999).to_s, - client_id: rand(9999).to_s, - client_secret: rand(9999).to_s - } - end - end end after do diff --git a/spec/sony_ci_api/error_spec.rb b/spec/sony_ci_api/error_spec.rb index 19b341a..7af7b03 100644 --- a/spec/sony_ci_api/error_spec.rb +++ b/spec/sony_ci_api/error_spec.rb @@ -32,7 +32,7 @@ expected_mappings.each do |faraday_error_class, expected_error_class| # Create an instance of the Faraday error class. Use nil message and # empty response because we don't need those, but Faraday classes do. - faraday_error = faraday_error_class.new(nil, {}) + faraday_error_class.new(nil, {}) new_error = described_class.create_from(faraday_error_class.new(nil, {})) expect(new_error).to be_a expected_error_class end