-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #619 from troessner/xml_report_fixes
I accidentally the whole XMLReport
- Loading branch information
Showing
3 changed files
with
47 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,25 @@ | ||
require 'pathname' | ||
require_relative '../../spec_helper' | ||
require_relative '../../../lib/reek/examiner' | ||
require_relative '../../../lib/reek/report/report' | ||
require_relative '../../../lib/reek/report/formatter' | ||
|
||
RSpec.describe Reek::Report::XMLReport do | ||
let(:instance) { Reek::Report::XMLReport.new } | ||
let(:xml_report) { Reek::Report::XMLReport.new } | ||
|
||
context 'empty source' do | ||
let(:examiner) { Reek::Examiner.new('') } | ||
|
||
before do | ||
instance.add_examiner examiner | ||
end | ||
|
||
it 'prints empty checkstyle xml' do | ||
expect { instance.show }.to output("<?xml version='1.0'?>\n<checkstyle/>\n").to_stdout | ||
it 'prints empty checkstyle XML' do | ||
xml_report.add_examiner Reek::Examiner.new('') | ||
xml = "<?xml version='1.0'?>\n<checkstyle/>\n" | ||
expect { xml_report.show }.to output(xml).to_stdout | ||
end | ||
end | ||
|
||
context 'source with voliations' do | ||
let(:examiner) { Reek::Examiner.new('def simple(a) a[0] end') } | ||
|
||
before do | ||
allow(File).to receive(:realpath).and_return('/some/path') | ||
instance.add_examiner examiner | ||
end | ||
|
||
it 'prints non-empty checkstyle xml' do | ||
sample_path = SAMPLES_PATH.join('checkstyle.xml') | ||
expect { instance.show }.to output(sample_path.read).to_stdout | ||
it 'prints non-empty checkstyle XML' do | ||
path = SAMPLES_PATH.join('two_smelly_files/dirty_one.rb') | ||
xml_report.add_examiner Reek::Examiner.new(path) | ||
xml = SAMPLES_PATH.join('checkstyle.xml').read | ||
xml = xml.gsub(path.to_s, path.expand_path.to_s) | ||
expect { xml_report.show }.to output(xml).to_stdout | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
<?xml version='1.0'?> | ||
<checkstyle><file name='/some/path'><error column='0' line='1' message='doesn't depend on instance state' severity='warning' source='UtilityFunction'/><error column='0' line='1' message='has the parameter name 'a'' severity='warning' source='UncommunicativeParameterName'/></file></checkstyle> | ||
<checkstyle> | ||
<file name='spec/samples/two_smelly_files/dirty_one.rb'> | ||
<error column='0' line='5' message='has the variable name '@s'' severity='warning' source='UncommunicativeVariableName'/> | ||
<error column='0' line='4' message='calls @s.title 2 times' severity='warning' source='DuplicateMethodCall'/> | ||
<error column='0' line='6' message='calls @s.title 2 times' severity='warning' source='DuplicateMethodCall'/> | ||
<error column='0' line='4' message='calls puts(@s.title) 2 times' severity='warning' source='DuplicateMethodCall'/> | ||
<error column='0' line='6' message='calls puts(@s.title) 2 times' severity='warning' source='DuplicateMethodCall'/> | ||
<error column='0' line='5' message='contains iterators nested 2 deep' severity='warning' source='NestedIterators'/> | ||
<error column='0' line='3' message='has the name 'a'' severity='warning' source='UncommunicativeMethodName'/> | ||
<error column='0' line='5' message='has the variable name 'x'' severity='warning' source='UncommunicativeVariableName'/> | ||
</file> | ||
</checkstyle> |