lib/rubocop/cop/rspec/multiple_memoized_helpers.rb in rubocop-rspec-2.0.0.pre vs lib/rubocop/cop/rspec/multiple_memoized_helpers.rb in rubocop-rspec-2.0.0
- old
+ new
@@ -83,11 +83,11 @@
# let(:bar) { [] }
# end
#
class MultipleMemoizedHelpers < Base
include ConfigurableMax
- include RuboCop::RSpec::Variable
+ include Variable
MSG = 'Example group has too many memoized helpers [%<count>d/%<max>d]'
def on_block(node)
return unless spec_group?(node)
@@ -99,10 +99,11 @@
self.max = count
add_offense(node, message: format(MSG, count: count, max: max))
end
def on_new_investigation
+ super
@example_group_memoized_helpers = {}
end
private
@@ -126,9 +127,10 @@
end
end
def variable_nodes(node)
example_group = RuboCop::RSpec::ExampleGroup.new(node)
+
if allow_subject?
example_group.lets
else
example_group.lets + example_group.subjects
end