Skip to content

Commit

Permalink
satisfy rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
markburns committed Jul 3, 2024
1 parent 9030381 commit 15ecc99
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 33 deletions.
2 changes: 2 additions & 0 deletions lib/interactify/configure.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Interactify
module Configure
def validate_app(ignore: [])
Expand Down
2 changes: 2 additions & 0 deletions lib/interactify/contracts/breaches.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Interactify
module Breaches
def self.handle_with_failure(context, breaches)
Expand Down
2 changes: 2 additions & 0 deletions lib/interactify/core.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Interactify
module Core
extend ActiveSupport::Concern
Expand Down
2 changes: 2 additions & 0 deletions lib/interactify/dependency_inference.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Interactify
class << self
delegate :on_definition_error, :trigger_definition_error, to: :configuration
Expand Down
2 changes: 2 additions & 0 deletions lib/interactify/hooks.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Interactify
module Hooks
def reset
Expand Down
2 changes: 2 additions & 0 deletions lib/interactify/with_options.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "interactify/core"
require "interactify/async/jobable"

Expand Down
4 changes: 2 additions & 2 deletions spec/lib/interactify.with_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
)

expect(async_klass.name).to match(/Optionified::Async__Queue_Within30Seconds__Retry_3(_\d+)?/)
async_klass.call!('choose_life' => true)
async_klass.call!("choose_life" => true)
Sidekiq::Worker.drain_all
end
end

module self::SomeNamespace
class Optionified
include Interactify.with(
queue: 'within_30_seconds',
queue: "within_30_seconds",
retry: 3
)
expect :choose_life, filled: false
Expand Down
12 changes: 6 additions & 6 deletions spec/lib/interactify/async/jobable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,20 +172,20 @@ def self.custom_method
context "with custom options and class suffix" do
class self::TestJobWithOptions
include Interactify::Async::Jobable
job_calling method_name: :parameter_method, opts: { queue: 'custom_queue' }, klass_suffix: 'Custom'
job_calling method_name: :parameter_method, opts: { queue: "custom_queue" }, klass_suffix: "Custom"

def self.parameter_method(param)
param
end
end

it "applies custom options to the job class" do
expect(self.class::TestJobWithOptions::JobCustom::JOBABLE_OPTS[:queue]).to eq('custom_queue')
expect(self.class::TestJobWithOptions::JobCustom::JOBABLE_OPTS[:queue]).to eq("custom_queue")
end

it "creates a job class with the specified suffix" do
job_instance = self.class::TestJobWithOptions::JobCustom.new
expect(job_instance.perform('test')).to eq('test')
expect(job_instance.perform("test")).to eq("test")
end
end

Expand All @@ -211,9 +211,9 @@ def self.sidekiq_method

expect(enqueued).to match(
a_hash_including(
'retry' => true,
'queue' => 'default',
'class' => self.class::TestJobWithSidekiq::Job.to_s
"retry" => true,
"queue" => "default",
"class" => self.class::TestJobWithSidekiq::Job.to_s
)
)
end
Expand Down
8 changes: 5 additions & 3 deletions spec/lib/interactify/core_spec.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# frozen_string_literal: true

RSpec.describe Interactify::Core do
self::DummyClass = Class.new do
include Interactify::Core
end

this = self

describe '#called_klass_list' do
describe "#called_klass_list" do
let(:dummy_context) do
ctx = Interactor::Context.new
allow(ctx).to receive(:_called) { [ 1, 2.3, 'some string' ] }
allow(ctx).to receive(:_called) { [1, 2.3, "some string"] }
ctx
end

subject do
this::DummyClass.new(dummy_context)
end

it 'returns the list of called classes' do
it "returns the list of called classes" do
expect(subject.called_klass_list).to eq([Integer, Float, String])
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/interactify/dsl/unique_klass_name_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
let(:first_name) { described_class.for(SpecSupport, "Whatever::Something", camelize:) }
let(:camelize) { true }

context 'when camelizing' do
context "when camelizing" do
let(:camelize) { true }

it "generates a class name" do
expect(first_name).to match(/WhateverSomething(_\d+)?/)
end
end

context 'when not camelizing' do
context "when not camelizing" do
let(:camelize) { false }

it "generates a class name without spacing" do
Expand Down
14 changes: 7 additions & 7 deletions spec/lib/interactify/wiring_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,36 +93,36 @@ def f(path)
let(:result) { wiring.send(:ignore_klass?, wiring.ignore, klass) }

def self.it_ignores
it 'ignores' do
it "ignores" do
expect(result).to be true
end
end

context 'with an array of classes' do
context "with an array of classes" do
let(:ignore) { [klass] }

it_ignores
end

context 'with a regexp' do
context "with a regexp" do
let(:ignore) { [/Dummy/] }

it_ignores
end

context 'with a string' do
context "with a string" do
let(:ignore) { ["DummyInteractor"] }

it_ignores
end

context 'proc condition' do
context "proc condition" do
let(:ignore) { [->(k) { k.to_s =~ /DummyInteractor/ }] }

it_ignores
end

context 'empty ignore' do
context "empty ignore" do
let(:ignore) { [] }

it "does not ignore class" do
Expand All @@ -132,7 +132,7 @@ def self.it_ignores
end

describe "#format_error" do
let(:missing_keys) { [:foo, :bar] }
let(:missing_keys) { %i[foo bar] }
let(:interactor) { double("Interactor", klass: "SomeInteractor") }
let(:organizer) { double("Organizer", klass: "SomeOrganizer") }
let(:formatted_errors) { [] }
Expand Down
20 changes: 11 additions & 9 deletions spec/lib/interactify/with_options_spec.rb
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
# frozen_string_literal: true

RSpec.describe Interactify::WithOptions do
let(:dummy_class) { Class.new }

let(:sidekiq_opts) { { queue: 'critical', retry: 5 } }
let(:sidekiq_opts) { { queue: "critical", retry: 5 } }
let(:instance) { described_class.new(dummy_class, sidekiq_opts) }

describe '#setup' do
describe "#setup" do
before do
allow(dummy_class).to receive(:include).and_call_original
allow(dummy_class).to receive(:const_set).and_call_original
end

it 'includes core and async jobable modules in the receiver' do
it "includes core and async jobable modules in the receiver" do
expect(dummy_class).to receive(:include).with(Interactify::Core)
expect(dummy_class).to receive(:include).with(Interactify::Async::Jobable)
instance.setup
end

it 'defines job and async classes with correct suffixes based on options' do
it "defines job and async classes with correct suffixes based on options" do
suffix = instance.klass_suffix
expect(dummy_class).to receive(:const_set).with("Job#{suffix}", anything)
expect(dummy_class).to receive(:const_set).with("Async#{suffix}", anything)
instance.setup
end

context 'when options include valid keys' do
it 'does not raise an error' do
context "when options include valid keys" do
it "does not raise an error" do
expect { instance.setup }.not_to raise_error
end
end

context 'when options include invalid keys' do
let(:sidekiq_opts) { { invalid_key: 'value' } }
context "when options include invalid keys" do
let(:sidekiq_opts) { { invalid_key: "value" } }

it 'raises an ArgumentError' do
it "raises an ArgumentError" do
expect { instance.setup }.to raise_error(ArgumentError, /Invalid keys: \[:invalid_key\]/)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "debug"

require "./spec/support/coverage"
require "./spec/support/coverage"

require "interactify"

Expand Down
6 changes: 3 additions & 3 deletions spec/support/coverage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
require "simplecov-json"

SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::JSONFormatter
])
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::JSONFormatter
])

SimpleCov.start do
add_filter "/spec/"
Expand Down

0 comments on commit 15ecc99

Please sign in to comment.