Sha256: 1865380a996e4dfcec6c0db44d20ead460a7f90764f5ef25aec2af4e3eb6bb2f

Contents?: true

Size: 948 Bytes

Versions: 7

Compression:

Stored size: 948 Bytes

Contents

# frozen_string_literal: true
require 'rubocop/rspec/expect_offense'
# rubocop:disable Lint/DuplicateMethods

module RuboCop
  module RSpec
    module ExpectOffense
      # Yields to a block with `parse_processed_source` patched to not raise an
      # exception.
      #
      # RSpec's `expect_offense` helper calls a method called
      # `parse_processed_source` that parses source code and raises an exception
      # if it is not valid Ruby. Raising an exception prevents RuboCop from
      # calling the cop's `on_other_file` method for checking non-Ruby files.
      def allow_invalid_ruby(&block)
        alias :parse_processed_source :_parse_invalid_source
        yield block
        alias :parse_processed_source :_orig_parse_processed_source
      end

      alias :_orig_parse_processed_source :parse_processed_source

      def _parse_invalid_source(source, file = nil)
        parse_source(source, file)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
cookstyle-7.32.8 lib/rubocop/monkey_patches/allow_invalid_ruby.rb
cookstyle-7.32.7 lib/rubocop/monkey_patches/allow_invalid_ruby.rb
cookstyle-ng-8.0.0 lib/rubocop/monkey_patches/allow_invalid_ruby.rb
cookstyle-7.32.2 lib/rubocop/monkey_patches/allow_invalid_ruby.rb
cookstyle-7.32.1 lib/rubocop/monkey_patches/allow_invalid_ruby.rb
cookstyle-7.32.0 lib/rubocop/monkey_patches/allow_invalid_ruby.rb
cookstyle-7.31.9 lib/rubocop/monkey_patches/allow_invalid_ruby.rb