From d6c69373e54b76232f361aa631e7b6283d3c71ef Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Sat, 13 Jan 2018 00:17:30 +0800 Subject: [PATCH] Make sure it's not offending to use local ||= val --- .../cop/gitlab/predicate_memoization_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/rubocop/cop/gitlab/predicate_memoization_spec.rb b/spec/rubocop/cop/gitlab/predicate_memoization_spec.rb index 6c731139468..21fc4584654 100644 --- a/spec/rubocop/cop/gitlab/predicate_memoization_spec.rb +++ b/spec/rubocop/cop/gitlab/predicate_memoization_spec.rb @@ -70,6 +70,20 @@ describe RuboCop::Cop::Gitlab::PredicateMemoization do end end + context 'when source is a predicate method using local with ||=' do + it_behaves_like 'not registering offense' do + let(:source) do + <<~RUBY + class C + def really? + really ||= true + end + end + RUBY + end + end + end + context 'when source is a regular method memoizing via ivar' do it_behaves_like 'not registering offense' do let(:source) do