Skip to content

Commit

Permalink
Adapt to the latest Rubocop wishes
Browse files Browse the repository at this point in the history
  • Loading branch information
mediafinger committed Apr 19, 2024
1 parent 12270fc commit 876afd4
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 18 deletions.
21 changes: 21 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -42,6 +59,9 @@ RSpec/MultipleMemoizedHelpers:
RSpec/NestedGroups:
Max: 4

RSpec/PendingWithoutReason:
Enabled: false

Style/CaseLikeIf:
Enabled: false

Expand All @@ -53,6 +73,7 @@ Style/Documentation:

Style/DoubleNegation:
Enabled: true

Style/FrozenStringLiteralComment:
Enabled: false

Expand Down
2 changes: 2 additions & 0 deletions chimera_http_client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion lib/chimera_http_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions spec/chimera_http_client/server/connection_options_spec.rb
Original file line number Diff line number Diff line change
@@ -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" }
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/chimera_http_client/server/error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}" } }
Expand Down
2 changes: 1 addition & 1 deletion spec/chimera_http_client/server/queue_spec.rb
Original file line number Diff line number Diff line change
@@ -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" }

Expand Down
4 changes: 2 additions & 2 deletions spec/chimera_http_client/server/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/chimera_http_client/server/response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion spec/chimera_http_client/stubbed/error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion spec/chimera_http_client/stubbed/queue_spec.rb
Original file line number Diff line number Diff line change
@@ -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" }

Expand Down
6 changes: 3 additions & 3 deletions spec/chimera_http_client/stubbed/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion spec/chimera_http_client/stubbed/response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" } }
Expand Down

0 comments on commit 876afd4

Please sign in to comment.