Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
eitoball committed Apr 16, 2024
1 parent cdf0011 commit eba1f4d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions spec/rubocop/formatter/checkstyle_formatter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
# encoding: utf-8

require 'spec_helper'
require 'rubocop/rspec/cop_helper'
require 'stringio'
require 'rexml/document'

module RuboCop
module Formatter
describe CheckstyleFormatter do
include CopHelper

let(:severities) { %i[refactor convention warning error fatal] }
let(:cop) do
Cop::Cop.new.tap do |c|
c.send(:begin_investigation, RuboCop::ProcessedSource.new(file, 2.7, 'sample.rb'))
processed_source = RuboCop::ProcessedSource.new(file, 2.7, 'sample.rb')
if RuboCop::Version.version >= '1.40.0'
processed_source.registry = registry
end
c.send(:begin_investigation, processed_source)
source_buffer = Parser::Source::Buffer.new('sample.rb', 1).tap { |b| b.source = '' }
severities.each_with_index do |severity, index|
c.add_offense(nil, location: Parser::Source::Range.new(source_buffer, 0, index), message: severity.to_s)
range = Parser::Source::Range.new(source_buffer, 0, index)
c.add_offense(processed_source.ast, location: range, message: severity.to_s)
end
end
end
Expand Down

0 comments on commit eba1f4d

Please sign in to comment.