Skip to content

Commit

Permalink
chore: fix rubocop offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosgz committed Jul 10, 2024
1 parent a1681c4 commit c9a3b1d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions spec/esse/active_record/callbacks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@

describe '.registered?' do
it 'returns false if the callback is not registered' do
expect(described_class.registered?(:external, :create)).to eq(false)
expect(described_class.registered?(:external, :create)).to be(false)
end

it 'returns true if the callback is registered' do
described_class.register_callback(:external, :create, Class.new(Esse::ActiveRecord::Callback))
expect(described_class.registered?(:external, :create)).to eq(true)
expect(described_class.registered?(:external, :create)).to be(true)
end
end

Expand Down
10 changes: 7 additions & 3 deletions spec/esse/active_record/model/esse_callback_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ def self.clear
Thread.current[:dummy_callback_repo] = nil
end
end

class DumpTempCallback < Esse::ActiveRecord::Callback
def call(model)
DummyCallbackRepo.add [model, options, block_result]
end
end

class DumpTempCallbackOnCreate < DumpTempCallback; end

class DumpTempCallbackOnUpdate < DumpTempCallback; end

class DumpTempCallbackOnDestroy < DumpTempCallback; end

RSpec.describe Esse::ActiveRecord::Model, '.esse_callback' do
Expand Down Expand Up @@ -85,7 +89,7 @@ class DumpTempCallbackOnDestroy < DumpTempCallback; end
model_class.esse_callback('states:state', :temp, on: %i[create], custom: 'value') { :ok }
expect(model_class.esse_callbacks).to a_hash_including(
'states:state' => a_hash_including(
temp_on_create: match_array([DumpTempCallbackOnCreate, {custom: 'value'}, an_instance_of(Proc)]),
temp_on_create: contain_exactly(DumpTempCallbackOnCreate, {custom: 'value'}, an_instance_of(Proc)),
)
)
end
Expand Down Expand Up @@ -132,7 +136,7 @@ class DumpTempCallbackOnDestroy < DumpTempCallback; end
model_class.esse_callback('states:state', :temp, on: %i[update], custom: 'value') { :ok }
expect(model_class.esse_callbacks).to a_hash_including(
'states:state' => a_hash_including(
temp_on_update: match_array([DumpTempCallbackOnUpdate, {custom: 'value'}, an_instance_of(Proc)]),
temp_on_update: contain_exactly(DumpTempCallbackOnUpdate, {custom: 'value'}, an_instance_of(Proc)),
)
)
end
Expand Down Expand Up @@ -182,7 +186,7 @@ class DumpTempCallbackOnDestroy < DumpTempCallback; end
model_class.esse_callback('states:state', :temp, on: %i[destroy], custom: 'value') { :ok }
expect(model_class.esse_callbacks).to a_hash_including(
'states:state' => a_hash_including(
temp_on_destroy: match_array([DumpTempCallbackOnDestroy, {custom: 'value'}, an_instance_of(Proc)]),
temp_on_destroy: contain_exactly(DumpTempCallbackOnDestroy, {custom: 'value'}, an_instance_of(Proc)),
)
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
model_class.update_lazy_attribute_callback('states:state', :field, custom: 'value') { :ok }
expect(model_class.esse_callbacks).to a_hash_including(
'states:state' => a_hash_including(
update_lazy_attribute_on_create: match_array([Esse::ActiveRecord::Callbacks::UpdateLazyAttribute, { attribute_name: :field, custom: 'value'}, an_instance_of(Proc)]),
update_lazy_attribute_on_update: match_array([Esse::ActiveRecord::Callbacks::UpdateLazyAttribute, { attribute_name: :field, custom: 'value'}, an_instance_of(Proc)]),
update_lazy_attribute_on_destroy: match_array([Esse::ActiveRecord::Callbacks::UpdateLazyAttribute, { attribute_name: :field, custom: 'value'}, an_instance_of(Proc)]),
update_lazy_attribute_on_create: contain_exactly(Esse::ActiveRecord::Callbacks::UpdateLazyAttribute, { attribute_name: :field, custom: 'value'}, an_instance_of(Proc)),
update_lazy_attribute_on_update: contain_exactly(Esse::ActiveRecord::Callbacks::UpdateLazyAttribute, { attribute_name: :field, custom: 'value'}, an_instance_of(Proc)),
update_lazy_attribute_on_destroy: contain_exactly(Esse::ActiveRecord::Callbacks::UpdateLazyAttribute, { attribute_name: :field, custom: 'value'}, an_instance_of(Proc)),
)
)
end
Expand All @@ -52,7 +52,7 @@
model_class.update_lazy_attribute_callback('states:state', :field, on: %i[create], custom: 'value') { :ok }
expect(model_class.esse_callbacks).to a_hash_including(
'states:state' => a_hash_including(
update_lazy_attribute_on_create: match_array([Esse::ActiveRecord::Callbacks::UpdateLazyAttribute, { attribute_name: :field, custom: 'value'}, an_instance_of(Proc)]),
update_lazy_attribute_on_create: contain_exactly(Esse::ActiveRecord::Callbacks::UpdateLazyAttribute, { attribute_name: :field, custom: 'value'}, an_instance_of(Proc)),
)
)
end
Expand All @@ -68,7 +68,7 @@
model_class.update_lazy_attribute_callback('states:state', :field, on: %i[update], custom: 'value') { :ok }
expect(model_class.esse_callbacks).to a_hash_including(
'states:state' => a_hash_including(
update_lazy_attribute_on_update: match_array([Esse::ActiveRecord::Callbacks::UpdateLazyAttribute, { attribute_name: :field, custom: 'value'}, an_instance_of(Proc)]),
update_lazy_attribute_on_update: contain_exactly(Esse::ActiveRecord::Callbacks::UpdateLazyAttribute, { attribute_name: :field, custom: 'value'}, an_instance_of(Proc)),
)
)
end
Expand All @@ -84,7 +84,7 @@
model_class.update_lazy_attribute_callback('states:state', :field, on: %i[destroy], custom: 'value') { :ok }
expect(model_class.esse_callbacks).to a_hash_including(
'states:state' => a_hash_including(
update_lazy_attribute_on_destroy: match_array([Esse::ActiveRecord::Callbacks::UpdateLazyAttribute, { attribute_name: :field, custom: 'value'}, an_instance_of(Proc)]),
update_lazy_attribute_on_destroy: contain_exactly(Esse::ActiveRecord::Callbacks::UpdateLazyAttribute, { attribute_name: :field, custom: 'value'}, an_instance_of(Proc)),
)
)
end
Expand Down

0 comments on commit c9a3b1d

Please sign in to comment.