Skip to content

Commit

Permalink
Avoid send method when calling public methods
Browse files Browse the repository at this point in the history
  • Loading branch information
tkareine committed Aug 27, 2023
1 parent ea18ca6 commit 3b16e11
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion test/support/test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def get_minifier_cmd_count(count_file = 'minifier_cmd_count')

def get_send_results(obj, method_names)
method_names.each_with_object({}) do |method_name, acc|
acc[method_name] = obj.send(method_name)
acc[method_name] = obj.public_send(method_name)
end
end

Expand Down
16 changes: 8 additions & 8 deletions test/unit/asset_file_registry_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ def test_register_returns_different_development_file_collections_for_bundle_conf
].each do |spec|
define_method :"test_register_returns_same_#{spec.fetch(:description)}_for_same_source_and_destination_paths" do
with_fake_site do |site|
first = AssetFileRegistry.send(spec.fetch(:method), site, STAMP_SOURCE_PATH, 'assets/dest1.css')
second = AssetFileRegistry.send(spec.fetch(:method), site, STAMP_SOURCE_PATH, 'assets/dest1.css')
first = AssetFileRegistry.public_send(spec.fetch(:method), site, STAMP_SOURCE_PATH, 'assets/dest1.css')
second = AssetFileRegistry.public_send(spec.fetch(:method), site, STAMP_SOURCE_PATH, 'assets/dest1.css')

assert_same(first, second)
assert_equal(1, asset_file_registry_size)
Expand All @@ -138,8 +138,8 @@ def test_register_returns_different_development_file_collections_for_bundle_conf

define_method :"test_register_returns_different_#{spec.fetch(:description)}s_for_different_source_and_destination_paths" do
with_fake_site do |site|
first = AssetFileRegistry.send(spec.fetch(:method), site, STAMP_SOURCE_PATH, 'assets/dest1.css')
second = AssetFileRegistry.send(spec.fetch(:method), site, STAMP_SOURCE_PATH, 'assets/dest2.css')
first = AssetFileRegistry.public_send(spec.fetch(:method), site, STAMP_SOURCE_PATH, 'assets/dest1.css')
second = AssetFileRegistry.public_send(spec.fetch(:method), site, STAMP_SOURCE_PATH, 'assets/dest2.css')

refute_same first, second
assert_equal(2, asset_file_registry_size)
Expand All @@ -153,9 +153,9 @@ def test_register_returns_different_development_file_collections_for_bundle_conf
File.join(CSS_BUNDLE_SOURCE_DIR, file)
end
source_paths.each { |path| FileUtils.touch(path) }
first = AssetFileRegistry.send(spec.fetch(:method), site, source_paths[0], 'assets/dest1.css')
first = AssetFileRegistry.public_send(spec.fetch(:method), site, source_paths[0], 'assets/dest1.css')
err = assert_raises(RuntimeError) do
AssetFileRegistry.send(spec.fetch(:method), site, source_paths[1], 'assets/dest1.css')
AssetFileRegistry.public_send(spec.fetch(:method), site, source_paths[1], 'assets/dest1.css')
end

assert_equal(<<~MESSAGE, err.to_s)
Expand Down Expand Up @@ -201,7 +201,7 @@ def test_raise_exception_if_registering_bundle_file_with_same_destination_path_a
].each do |spec|
define_method :"test_remove_unused_#{spec.fetch(:description)}" do
with_fake_site do |site|
AssetFileRegistry.send(spec.fetch(:method), site, bundle_config)
AssetFileRegistry.public_send(spec.fetch(:method), site, bundle_config)
AssetFileRegistry.clear_unused

assert_equal(1, asset_file_registry_size)
Expand All @@ -219,7 +219,7 @@ def test_raise_exception_if_registering_bundle_file_with_same_destination_path_a
].each do |spec|
define_method :"test_remove_unused_#{spec.fetch(:description)}" do
with_fake_site do |site|
AssetFileRegistry.send(spec.fetch(:method), site, STAMP_SOURCE_PATH, STAMP_DESTINATION_PATH)
AssetFileRegistry.public_send(spec.fetch(:method), site, STAMP_SOURCE_PATH, STAMP_DESTINATION_PATH)
AssetFileRegistry.clear_unused

assert_equal(1, asset_file_registry_size)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/jekyll_static_file_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def response_types_of_methods(file, methods)
methods.each_with_object({}) do |method_name, acc|
acc[method_name] =
begin
value = file.send(method_name)
value = file.public_send(method_name)
{returned_type: value.class}
rescue StandardError => e
{raised: e}
Expand Down

0 comments on commit 3b16e11

Please sign in to comment.