Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7541b72
commit 4db1b6d
Showing
5 changed files
with
77 additions
and
18 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
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
File renamed without changes.
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,19 +1,78 @@ | ||
require 'spec_helper' | ||
|
||
describe Codeqa::RunnerDecorator do | ||
it 'should run provide the errors if the checker failed' do | ||
source = source_with('def syntax_error', 'ruby.rb') | ||
runner = Codeqa::Runner.run(source) | ||
expect(runner.success?).to be false | ||
decorator = Codeqa::RunnerDecorator.new(runner) | ||
expect(decorator.to_s).to match(/syntax/) | ||
let(:errors){ Codeqa::CheckErrors.new } | ||
let(:decorator) do | ||
checker = double(Codeqa::Checker, :errors => errors, | ||
:name => 'test', | ||
:hint => 'testtest') | ||
runner = double(Codeqa::Runner, :failures => [checker], | ||
:sourcefile => Codeqa::Sourcefile.new('foo.rb', 'foo'), | ||
:success? => false) | ||
Codeqa::RunnerDecorator.new(runner) | ||
end | ||
it 'should run list the ran checkers' do | ||
source = source_with('def foo; end', 'ruby.rb') | ||
runner = Codeqa::Runner.run(source) | ||
expect(runner.success?).to be true | ||
decorator = Codeqa::RunnerDecorator.new(runner) | ||
expect(decorator.to_s).to match(/Passed tests.+strange chars/) | ||
|
||
it 'should format error as line if number given' do | ||
errors.add(77, 'test message') | ||
expect(decorator.details_to_s).to eq(<<-EOF) | ||
\e[31m------- test -------\e[0m | ||
\e[31mtesttest\e[0m | ||
Line: \e[33m77\e[0m|test message | ||
EOF | ||
end | ||
|
||
it 'should format error as position if array given' do | ||
errors.add([22, 77], 'test message') | ||
expect(decorator.details_to_s).to eq(<<-EOF) | ||
\e[31m------- test -------\e[0m | ||
\e[31mtesttest\e[0m | ||
Pos: \e[33m22,77\e[0m|test message | ||
EOF | ||
end | ||
|
||
it 'should simply print error content if no context is given' do | ||
errors.add(nil, 'test message') | ||
expect(decorator.details_to_s).to eq(<<-EOF) | ||
\e[31m------- test -------\e[0m | ||
\e[31mtesttest\e[0m | ||
test message | ||
EOF | ||
end | ||
|
||
it 'should format error as source if :source token given' do | ||
errors.add(:source, 'test message') | ||
expect(decorator.details_to_s).to eq(<<-EOF) | ||
\e[31m------- test -------\e[0m | ||
\e[31mtesttest\e[0m | ||
\e[33m 1\e[0m|test message | ||
EOF | ||
end | ||
|
||
it 'should correctly format multiline source' do | ||
errors.add(:source, "test message\nline two\nthird\n\nfifth") | ||
expect(decorator.details_to_s).to eq(<<-EOF) | ||
\e[31m------- test -------\e[0m | ||
\e[31mtesttest\e[0m | ||
\e[33m 1\e[0m|test message | ||
\e[33m 2\e[0m|line two | ||
\e[33m 3\e[0m|third | ||
\e[33m 4\e[0m| | ||
\e[33m 5\e[0m|fifth | ||
EOF | ||
end | ||
# it 'should run provide the errors if the checker failed' do | ||
# source = source_with('def syntax_error', 'ruby.rb') | ||
# runner = Codeqa::Runner.run(source) | ||
# expect(runner.success?).to be false | ||
# decorator = Codeqa::RunnerDecorator.new(runner) | ||
# expect(decorator.to_s).to match(/syntax/) | ||
# end | ||
# it 'should run list the ran checkers' do | ||
# source = source_with('def foo; end', 'ruby.rb') | ||
# runner = Codeqa::Runner.run(source) | ||
# expect(runner.success?).to be true | ||
# decorator = Codeqa::RunnerDecorator.new(runner) | ||
# expect(decorator.to_s).to match(/Passed tests.+strange chars/) | ||
# end | ||
|
||
end |