diff --git a/.rubocop.yml b/.rubocop.yml index 7520fda..7a4f0e1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,10 +6,14 @@ AllCops: TargetRubyVersion: 2.5 DisplayCopNames: true NewCops: enable # but feel free to disable them below + SuggestExtensions: false Exclude: - vendor/**/* - config.ru +Gemspec/DevelopmentDependencies: + EnforcedStyle: gemspec + Layout/EmptyLineBetweenDefs: AllowAdjacentOneLineDefs: true @@ -27,12 +31,25 @@ Layout/LineLength: Metrics: Enabled: false +RSpec/ClassCheck: + Enabled: false + RSpec/ContextWording: Enabled: false RSpec/ExampleLength: Max: 25 +RSpec/FilePath: + Exclude: + - spec/chimera_http_client/server/* + - spec/chimera_http_client/stubbed/* + +RSpec/SpecFilePathFormat: + Exclude: + - spec/chimera_http_client/server/* + - spec/chimera_http_client/stubbed/* + - RSpec/MultipleExpectations: Enabled: false @@ -42,6 +59,9 @@ RSpec/MultipleMemoizedHelpers: RSpec/NestedGroups: Max: 4 +RSpec/PendingWithoutReason: + Enabled: false + Style/CaseLikeIf: Enabled: false @@ -53,6 +73,7 @@ Style/Documentation: Style/DoubleNegation: Enabled: true + Style/FrozenStringLiteralComment: Enabled: false diff --git a/chimera_http_client.gemspec b/chimera_http_client.gemspec index ebeb3dd..9e127fa 100644 --- a/chimera_http_client.gemspec +++ b/chimera_http_client.gemspec @@ -27,6 +27,8 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] + spec.metadata["rubygems_mfa_required"] = "true" + # the only sub-dependencies spec.add_runtime_dependency "typhoeus", "~> 1.1" spec.add_runtime_dependency "zeitwerk", ">= 2.0" diff --git a/lib/chimera_http_client.rb b/lib/chimera_http_client.rb index d1af6af..b73259f 100644 --- a/lib/chimera_http_client.rb +++ b/lib/chimera_http_client.rb @@ -7,5 +7,5 @@ module ChimeraHttpClient loader.setup # as Zeitwerk can't handle innner classes properly :-/ - require_relative "./chimera_http_client/error" + require_relative "chimera_http_client/error" end diff --git a/spec/chimera_http_client/server/connection_options_spec.rb b/spec/chimera_http_client/server/connection_options_spec.rb index 6a1f4bc..8ea89af 100644 --- a/spec/chimera_http_client/server/connection_options_spec.rb +++ b/spec/chimera_http_client/server/connection_options_spec.rb @@ -1,6 +1,6 @@ require "server_spec_helper" -describe ChimeraHttpClient::Connection do # rubocop:disable RSpec/FilePath +describe ChimeraHttpClient::Connection do let(:connection) { described_class.new(base_url: base_url) } let(:base_url) { "#{UsersServer.endpoint_url}/api/v1" } let(:endpoint) { "users/22" } @@ -46,11 +46,11 @@ it "records request and custom context information" do expect { get }.to output( - "url: #{base_url}/users/22\n"\ - "method: get\n"\ - "status: 200\n"\ - "runtime: 0.015\n"\ - "completed_at: #{frozen_time}\n"\ + "url: #{base_url}/users/22\n" \ + "method: get\n" \ + "status: 200\n" \ + "runtime: 0.015\n" \ + "completed_at: #{frozen_time}\n" \ "context: {:user_id=>90210}\n" ).to_stdout end diff --git a/spec/chimera_http_client/server/error_spec.rb b/spec/chimera_http_client/server/error_spec.rb index 4ecec4a..614dd42 100644 --- a/spec/chimera_http_client/server/error_spec.rb +++ b/spec/chimera_http_client/server/error_spec.rb @@ -30,7 +30,7 @@ let(:connection) { ChimeraHttpClient::Connection.new(base_url: base_url, deserializer: deserializer, timeout: timeout) } let(:base_url) { "#{UsersServer.endpoint_url}/api/v1" } - let(:deserializer) { { error: ::ChimeraHttpClient::Deserializer.json_error } } + let(:deserializer) { { error: ChimeraHttpClient::Deserializer.json_error } } let(:timeout) { 0.2 } let(:expected_parsed_body) { { message: "error #{failure_code}" } } diff --git a/spec/chimera_http_client/server/queue_spec.rb b/spec/chimera_http_client/server/queue_spec.rb index fff68f1..aaa0971 100644 --- a/spec/chimera_http_client/server/queue_spec.rb +++ b/spec/chimera_http_client/server/queue_spec.rb @@ -1,6 +1,6 @@ require "server_spec_helper" -describe ChimeraHttpClient::Queue do # rubocop:disable RSpec/FilePath +describe ChimeraHttpClient::Queue do let(:queue) { described_class.new(base_url: base_url) } let(:base_url) { "#{UsersServer.endpoint_url}/api/v1" } diff --git a/spec/chimera_http_client/server/request_spec.rb b/spec/chimera_http_client/server/request_spec.rb index ee684cd..81e1459 100644 --- a/spec/chimera_http_client/server/request_spec.rb +++ b/spec/chimera_http_client/server/request_spec.rb @@ -16,11 +16,11 @@ end it "does not have a response" do - expect(request.request.response).to eq(nil) + expect(request.request.response).to be_nil end it "does have an empty result" do - expect(request.result).to eq(nil) + expect(request.result).to be_nil end end diff --git a/spec/chimera_http_client/server/response_spec.rb b/spec/chimera_http_client/server/response_spec.rb index 23cd8be..c48545f 100644 --- a/spec/chimera_http_client/server/response_spec.rb +++ b/spec/chimera_http_client/server/response_spec.rb @@ -20,7 +20,7 @@ let(:connection) { ChimeraHttpClient::Connection.new(base_url: base_url, deserializer: deserializer, timeout: timeout) } let(:base_url) { "#{UsersServer.endpoint_url}/api/v1" } - let(:deserializer) { { response: ::ChimeraHttpClient::Deserializer.json_response } } + let(:deserializer) { { response: ChimeraHttpClient::Deserializer.json_response } } let(:timeout) { 0.2 } let(:response_code) { 200 } diff --git a/spec/chimera_http_client/stubbed/error_spec.rb b/spec/chimera_http_client/stubbed/error_spec.rb index c2fe843..3d4e89b 100644 --- a/spec/chimera_http_client/stubbed/error_spec.rb +++ b/spec/chimera_http_client/stubbed/error_spec.rb @@ -31,7 +31,7 @@ Typhoeus::Response.new(code: failure_code, body: failure_body, total_time: response_time) .tap { |resp| resp.request = Typhoeus::Request.new(base_url, method: method) } end - let(:deserializer) { { error: ::ChimeraHttpClient::Deserializer.json_error } } + let(:deserializer) { { error: ChimeraHttpClient::Deserializer.json_error } } let(:expected_parsed_body) { { "errors" => [{ "code" => failure_code }] } } let(:failure_body) { expected_parsed_body.to_json } let(:response_time) { 0.5 } diff --git a/spec/chimera_http_client/stubbed/queue_spec.rb b/spec/chimera_http_client/stubbed/queue_spec.rb index 13ca9f2..b310c6a 100644 --- a/spec/chimera_http_client/stubbed/queue_spec.rb +++ b/spec/chimera_http_client/stubbed/queue_spec.rb @@ -1,6 +1,6 @@ require "spec_helper" -describe ChimeraHttpClient::Queue do # rubocop:disable RSpec/FilePath +describe ChimeraHttpClient::Queue do let(:queue) { described_class.new(base_url: base_url) } let(:base_url) { "http://127.0.0.1:3000/v1" } diff --git a/spec/chimera_http_client/stubbed/request_spec.rb b/spec/chimera_http_client/stubbed/request_spec.rb index 65d4887..31455fe 100644 --- a/spec/chimera_http_client/stubbed/request_spec.rb +++ b/spec/chimera_http_client/stubbed/request_spec.rb @@ -16,11 +16,11 @@ end it "does not have a response" do - expect(request.request.response).to eq(nil) + expect(request.request.response).to be_nil end it "does have an empty result" do - expect(request.result).to eq(nil) + expect(request.result).to be_nil end end @@ -29,7 +29,7 @@ let(:url) { "http://127.0.0.1/dummy" } let(:typhoeus_response) { Typhoeus::Response.new(code: response_code, body: response_json, total_time: response_time) } - let(:deserializer) { { error: ::ChimeraHttpClient::Deserializer.json_error } } + let(:deserializer) { { error: ChimeraHttpClient::Deserializer.json_error } } let(:response_body) { { "id" => 42, "name" => "Andy" } } let(:response_json) { response_body.to_json } let(:response_time) { 0.5 } diff --git a/spec/chimera_http_client/stubbed/response_spec.rb b/spec/chimera_http_client/stubbed/response_spec.rb index 28f3141..1ac7796 100644 --- a/spec/chimera_http_client/stubbed/response_spec.rb +++ b/spec/chimera_http_client/stubbed/response_spec.rb @@ -18,7 +18,7 @@ subject(:response) { described_class.new(typhoeus_response, deserializer: deserializer) } let(:typhoeus_response) { Typhoeus::Response.new(code: response_code, body: response_json, total_time: response_time) } - let(:deserializer) { { response: ::ChimeraHttpClient::Deserializer.json_response } } + let(:deserializer) { { response: ChimeraHttpClient::Deserializer.json_response } } let(:response_code) { 200 } let(:response_body) { { "id" => 42, "name" => "Andy" } }