File: expect_offense.rb

package info (click to toggle)
ruby-rubocop-rspec 2.16.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,892 kB
  • sloc: ruby: 22,283; makefile: 4
file content (27 lines) | stat: -rw-r--r-- 696 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

# rubocop-rspec gem extension of RuboCop's ExpectOffense module.
#
# This mixin is the same as rubocop's ExpectOffense except the default
# filename ends with `_spec.rb`
#
# Cops assigned to departments may focus on different files, so it is
# possible to override the inspected file name.
module ExpectOffense
  include RuboCop::RSpec::ExpectOffense

  DEFAULT_FILENAME = 'example_spec.rb'

  def expect_offense(source, filename = inspected_source_filename,
                     *args, **kwargs)
    super
  end

  def expect_no_offenses(source, filename = inspected_source_filename)
    super
  end

  def inspected_source_filename
    DEFAULT_FILENAME
  end
end