Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-07-14 03:09:32 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-14 03:09:32 +0300
commit804348d39bc1815441c6c4d901a2cf32d5136f9a (patch)
treea3ec6279260b84faa6561dfc21dc411a2834387d /spec/rubocop
parent75f2fd2ba85fea64ee1a42f704c4872282f55eb5 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop')
-rw-r--r--spec/rubocop/cop/gitlab/strong_memoize_attr_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/rubocop/cop/gitlab/strong_memoize_attr_spec.rb b/spec/rubocop/cop/gitlab/strong_memoize_attr_spec.rb
index fde53f8f98c..75455a390f4 100644
--- a/spec/rubocop/cop/gitlab/strong_memoize_attr_spec.rb
+++ b/spec/rubocop/cop/gitlab/strong_memoize_attr_spec.rb
@@ -100,4 +100,42 @@ RSpec.describe RuboCop::Cop::Gitlab::StrongMemoizeAttr do
RUBY
end
end
+
+ context 'when strong_memoize_with() is called without parameters' do
+ it 'registers an offense and autocorrects' do
+ expect_offense(<<~RUBY)
+ class Foo
+ def memoized_method
+ strong_memoize_with(:memoized_method) do
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `strong_memoize_attr`, instead of using `strong_memoize_with` without parameters.
+ 'This is a memoized method'
+ end
+ end
+ end
+ RUBY
+
+ expect_correction(<<~RUBY)
+ class Foo
+ def memoized_method
+ 'This is a memoized method'
+ end
+ strong_memoize_attr :memoized_method
+ end
+ RUBY
+ end
+ end
+
+ context 'when strong_memoize_with() is called with parameters' do
+ it 'does not register an offense' do
+ expect_no_offenses(<<~RUBY)
+ class Foo
+ def memoized_method(param)
+ strong_memoize_with(:memoized_method, param) do
+ param.to_s
+ end
+ end
+ end
+ RUBY
+ end
+ end
end