From 7441c7af9acb849ba5f6a25895614fe5cc8023b2 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Fri, 17 Nov 2017 21:25:49 +0800 Subject: Allow initialize method and single ivar --- .../cop/module_with_instance_variables_spec.rb | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'spec/rubocop') diff --git a/spec/rubocop/cop/module_with_instance_variables_spec.rb b/spec/rubocop/cop/module_with_instance_variables_spec.rb index bac39117dba..72f6b01aa81 100644 --- a/spec/rubocop/cop/module_with_instance_variables_spec.rb +++ b/spec/rubocop/cop/module_with_instance_variables_spec.rb @@ -137,6 +137,35 @@ describe RuboCop::Cop::ModuleWithInstanceVariables do it_behaves_like 'not registering offense' end + context 'when source is using simple ivar' do + let(:source) do + <<~RUBY + module M + def f? + @f + end + end + RUBY + end + + it_behaves_like 'not registering offense' + end + + context 'when source is defining initialize' do + let(:source) do + <<~RUBY + module M + def initialize + @a = 1 + @b = 2 + end + end + RUBY + end + + it_behaves_like 'not registering offense' + end + context 'when source is using simple or ivar assignment with other ivar' do let(:source) do <<~RUBY -- cgit v1.2.1