diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-11-17 16:25:49 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-11-17 20:01:53 +0300 |
commit | 7441c7af9acb849ba5f6a25895614fe5cc8023b2 (patch) | |
tree | b987741c38ec964592df29a4cf6d90eeac420566 /spec | |
parent | 9ac0c76b78cd04b2505924f003dd720a0f155959 (diff) |
Allow initialize method and single ivar
Diffstat (limited to 'spec')
-rw-r--r-- | spec/rubocop/cop/module_with_instance_variables_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
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 |