class RuboCop::Cop::RSpec::NoExpectationExample


end
assert_something
it do
end
expect_something
it do
# good
end
not_expect_something
it do
# bad
@example
# - ^assert_
# - ^expect_
# AllowedPatterns:
# RSpec/NoExpectationExample:
# .rubocop.yml
@example ‘AllowedPatterns` configuration
by default.
with an `AllowedPatterns` option. ^expect_ and ^assert_ are allowed
This cop can be customized with an allowed expectation methods pattern
end
expect(a?).to be(true)
it do
# good
end
a?
it do
# bad
@example
- custom_expect
Expectations:
- custom_it
Regular:
Examples:
Language:
RSpec:
add the following configuration:
If you are using your own custom methods,
All RSpec’s example and expectation methods are covered by default.
Checks if an example contains any expectation.

def on_block(node)

Parameters:
  • node (RuboCop::AST::BlockNode) --
def on_block(node)
  return unless regular_or_focused_example?(node)
  return if includes_expectation?(node)
  return if includes_skip_example?(node)
  return if skipped_in_metadata?(node.send_node)
  add_offense(node)
end