class RuboCop::Cop::RSpec::AroundBlock
end
test.run
some_method
around do |test|
end
test.call
some_method
around do |test|
# good
end
some_method
around do |test|
end
some_method
around do
# bad
@example
Checks that around blocks actually run the test.
def add_no_arg_offense(node)
def add_no_arg_offense(node) add_offense(node, message: MSG_NO_ARG) end
def check_for_numblock(block)
def check_for_numblock(block) find_arg_usage(block) do |usage| return if usage.include?(s(:lvar, :_1)) end add_offense( block.children.last, message: format(MSG_UNUSED_ARG, arg: :_1) ) end
def check_for_unused_proxy(block, proxy)
def check_for_unused_proxy(block, proxy) find_arg_usage(block) do |usage| return if usage.include?(s(:lvar, proxy.name)) end add_offense( proxy, message: format(MSG_UNUSED_ARG, arg: proxy.name) ) end
def on_block(node)
def on_block(node) hook_block(node) do |(example_proxy)| if example_proxy.nil? add_no_arg_offense(node) else check_for_unused_proxy(node, example_proxy) end end end
def on_numblock(node)
def on_numblock(node) hook_numblock(node) do check_for_numblock(node) end end