Skip to content

Commit

Permalink
Allow for --auto-gen-config
Browse files Browse the repository at this point in the history
  • Loading branch information
pirj committed Aug 7, 2020
1 parent ad3558f commit 1de92ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/rubocop/cop/rspec/multiple_memoized_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ module RSpec
# end
#
class MultipleMemoizedHelpers < Base
include ConfigurableMax
include RuboCop::RSpec::Variable

MSG = 'Example group has too many memoized helpers [%<count>d/%<max>d]'
Expand All @@ -99,6 +100,7 @@ def on_block(node)

return if count <= max

self.max = count
add_offense(node, message: format(MSG, count: count, max: max))
end

Expand Down
13 changes: 13 additions & 0 deletions spec/rubocop/cop/rspec/multiple_memoized_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,17 @@
RUBY
end
end

it 'support --auto-gen-config' do
inspect_source(<<-RUBY, 'spec/foo_spec.rb')
describe Foo do
let(:foo) { Foo.new }
let(:bar) { Bar.new }
let(:baz) { Baz.new }
let(:qux) { Qux.new }
end
RUBY

expect(cop.config_to_allow_offenses[:exclude_limit]).to eq('Max' => 4)
end
end

0 comments on commit 1de92ab

Please sign in to comment.