lib/rubocop/cop/rspec/pending_without_reason.rb in rubocop-rspec-2.16.0 vs lib/rubocop/cop/rspec/pending_without_reason.rb in rubocop-rspec-2.17.0
- old
+ new
@@ -85,38 +85,36 @@
# @!method skipped_by_metadata_without_reason?(node)
def_node_matcher :skipped_by_metadata_without_reason?, <<~PATTERN
(send #rspec? {#ExampleGroups.all #Examples.all} ... {<(sym :skip) ...> (hash <(pair (sym :skip) true) ...>)})
PATTERN
+ # @!method without_reason?(node)
+ def_node_matcher :without_reason?, <<~PATTERN
+ (send nil? ${:pending :skip})
+ PATTERN
+
def on_send(node)
if pending_without_reason?(node)
add_offense(node, message: 'Give the reason for pending.')
elsif skipped_without_reason?(node)
add_offense(node, message: 'Give the reason for skip.')
+ elsif without_reason?(node) && example?(node.parent)
+ add_offense(node,
+ message: "Give the reason for #{node.method_name}.")
end
end
private
- def pending_by_pending_step_without_reason?(node)
- node.method?(:pending) && node.first_argument.nil?
- end
-
def pending_without_reason?(node)
pending_by_example_method?(node.block_node) ||
- pending_by_metadata_without_reason?(node) ||
- pending_by_pending_step_without_reason?(node)
+ pending_by_metadata_without_reason?(node)
end
- def skipped_by_skip_step_without_reason?(node)
- node.method?(:skip) && node.first_argument.nil?
- end
-
def skipped_without_reason?(node)
skipped_by_example_group_method?(node.block_node) ||
skipped_by_example_method?(node.block_node) ||
- skipped_by_metadata_without_reason?(node) ||
- skipped_by_skip_step_without_reason?(node)
+ skipped_by_metadata_without_reason?(node)
end
end
end
end
end