coveralls_reborn 0.26.0 → 0.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/LICENSE +1 -1
- data/README.md +155 -4
- data/lib/coveralls/configuration.rb +12 -0
- data/lib/coveralls/version.rb +1 -1
- metadata +3 -53
- data/.github/dependabot.yml +0 -8
- data/.github/workflows/rubocop.yml +0 -29
- data/.github/workflows/ruby.yml +0 -53
- data/.gitignore +0 -22
- data/.rspec +0 -2
- data/.rubocop.yml +0 -59
- data/Gemfile +0 -20
- data/Rakefile +0 -18
- data/coveralls-ruby.gemspec +0 -36
- data/spec/coveralls/configuration_spec.rb +0 -435
- data/spec/coveralls/coveralls_spec.rb +0 -127
- data/spec/coveralls/fixtures/app/controllers/sample.rb +0 -14
- data/spec/coveralls/fixtures/app/models/airplane.rb +0 -12
- data/spec/coveralls/fixtures/app/models/dog.rb +0 -10
- data/spec/coveralls/fixtures/app/models/house.rb +0 -10
- data/spec/coveralls/fixtures/app/models/robot.rb +0 -10
- data/spec/coveralls/fixtures/app/models/user.rb +0 -16
- data/spec/coveralls/fixtures/app/vendor/vendored_gem.rb +0 -1
- data/spec/coveralls/fixtures/sample.rb +0 -12
- data/spec/coveralls/output_spec.rb +0 -81
- data/spec/coveralls/simple_cov/formatter_spec.rb +0 -141
- data/spec/spec_helper.rb +0 -83
@@ -1,81 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Coveralls::Output do
|
6
|
-
it 'defaults the IO to $stdout' do
|
7
|
-
expect { described_class.puts 'this is a test' }.to output("this is a test\n").to_stdout
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'accepts an IO injection' do
|
11
|
-
out = StringIO.new
|
12
|
-
allow(described_class).to receive(:output).and_return(out)
|
13
|
-
described_class.puts 'this is a test'
|
14
|
-
|
15
|
-
expect(out.string).to eq "this is a test\n"
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '.puts' do
|
19
|
-
it 'accepts an IO injection' do
|
20
|
-
out = StringIO.new
|
21
|
-
described_class.puts 'this is a test', output: out
|
22
|
-
|
23
|
-
expect(out.string).to eq "this is a test\n"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '.print' do
|
28
|
-
it 'accepts an IO injection' do
|
29
|
-
out = StringIO.new
|
30
|
-
described_class.print 'this is a test', output: out
|
31
|
-
|
32
|
-
expect(out.string).to eq 'this is a test'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe 'when silenced' do
|
37
|
-
before { described_class.silent = true }
|
38
|
-
|
39
|
-
it 'does not put' do
|
40
|
-
expect { described_class.puts 'foo' }.not_to output("foo\n").to_stdout
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'does not print' do
|
44
|
-
expect { described_class.print 'foo' }.not_to output('foo').to_stdout
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '.format' do
|
49
|
-
it 'accepts a color argument' do
|
50
|
-
require 'term/ansicolor'
|
51
|
-
string = 'Hello'
|
52
|
-
ansi_color_string = Term::ANSIColor.red(string)
|
53
|
-
expect(described_class.format(string, color: 'red')).to eq(ansi_color_string)
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'accepts no color arguments' do
|
57
|
-
unformatted_string = 'Hi Doggie!'
|
58
|
-
expect(described_class.format(unformatted_string)).to eq(unformatted_string)
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'rejects formats unrecognized by Term::ANSIColor' do
|
62
|
-
string = 'Hi dog!'
|
63
|
-
expect(described_class.format(string, color: 'not_a_real_color')).to eq(string)
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'accepts more than 1 color argument' do
|
67
|
-
string = 'Hi dog!'
|
68
|
-
multi_formatted_string = Term::ANSIColor.red { Term::ANSIColor.underline(string) }
|
69
|
-
expect(described_class.format(string, color: 'red underline')).to eq(multi_formatted_string)
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'without color' do
|
73
|
-
before { described_class.no_color = true }
|
74
|
-
|
75
|
-
it 'does not add color to string' do
|
76
|
-
unformatted_string = 'Hi Doggie!'
|
77
|
-
expect(described_class.format(unformatted_string, color: 'red')).to eq(unformatted_string)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,141 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Coveralls::SimpleCov::Formatter do
|
6
|
-
before do
|
7
|
-
stub_api_post
|
8
|
-
end
|
9
|
-
|
10
|
-
def source_fixture(filename)
|
11
|
-
File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures', filename))
|
12
|
-
end
|
13
|
-
|
14
|
-
let(:result) do
|
15
|
-
options = {
|
16
|
-
source_fixture('app/controllers/sample.rb') => { lines: [nil, 1, 1, 1, nil, 0, 1, 1, nil, nil] },
|
17
|
-
source_fixture('app/models/airplane.rb') => { lines: [0, 0, 0, 0, 0] },
|
18
|
-
source_fixture('app/models/dog.rb') => { lines: [1, 1, 1, 1, 1] },
|
19
|
-
source_fixture('app/models/house.rb') => { lines: [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil] },
|
20
|
-
source_fixture('app/models/robot.rb') => { lines: [1, 1, 1, 1, nil, nil, 1, 0, nil, nil] },
|
21
|
-
source_fixture('app/models/user.rb') => {
|
22
|
-
lines: [nil, 1, 1, 0, nil, nil, 1, 0, nil, nil, 1, 0, 0, nil, nil, nil],
|
23
|
-
'branches' => {
|
24
|
-
'[:if, 0, 12, 4, 14, 7]' => {
|
25
|
-
'[:then, 1, 13, 6, 13, 11]' => 1,
|
26
|
-
'[:else, 2, 12, 4, 14, 7]' => 0
|
27
|
-
}
|
28
|
-
}
|
29
|
-
},
|
30
|
-
source_fixture('sample.rb') => { lines: [nil, 1, 1, 1, nil, 0, 1, 1, nil, nil] }
|
31
|
-
}
|
32
|
-
|
33
|
-
SimpleCov::Result.new(options)
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '#format' do
|
37
|
-
context 'when should run' do
|
38
|
-
before do
|
39
|
-
Coveralls.testing = true
|
40
|
-
Coveralls.noisy = false
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'posts json' do
|
44
|
-
expect(result.files).not_to be_empty
|
45
|
-
silence do
|
46
|
-
expect(described_class.new.format(result)).to be_truthy
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'when should not run, noisy' do
|
52
|
-
it 'only displays result' do
|
53
|
-
silence do
|
54
|
-
expect(described_class.new.display_result(result)).to be_truthy
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'without files' do
|
60
|
-
let(:result) { SimpleCov::Result.new({}) }
|
61
|
-
|
62
|
-
it 'shows note that no files have been covered' do
|
63
|
-
Coveralls.noisy = true
|
64
|
-
Coveralls.testing = false
|
65
|
-
|
66
|
-
silence do
|
67
|
-
expect do
|
68
|
-
described_class.new.format(result)
|
69
|
-
end.not_to raise_error
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'with api error' do
|
75
|
-
it 'rescues' do
|
76
|
-
e = SocketError.new
|
77
|
-
|
78
|
-
silence do
|
79
|
-
expect(described_class.new.display_error(e)).to be_falsy
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe '#get_source_files' do
|
85
|
-
let(:source_files) { instance.get_source_files(result) }
|
86
|
-
let(:instance) do
|
87
|
-
described_class.new.tap do |ins|
|
88
|
-
allow(ins).to receive(:branches)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'nils the skipped lines' do
|
93
|
-
source_file = source_files.first
|
94
|
-
expect(source_file[:coverage]).to eq [nil, 1, 1, 1, nil, 0, 1, 1, nil, nil, nil, nil, nil]
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'calls #branches when branch coverage is present' do
|
98
|
-
source_files
|
99
|
-
expect(instance).to have_received(:branches).once
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
describe '#branches' do
|
104
|
-
let(:branch_coverage_parsed) { described_class.new.branches(simplecov_branches_results) }
|
105
|
-
let(:simplecov_branches_results) do
|
106
|
-
{
|
107
|
-
'[:if, 0, 12, 4, 14, 7]' => {
|
108
|
-
'[:then, 1, 13, 6, 13, 11]' => 1,
|
109
|
-
'[:else, 2, 12, 4, 14, 7]' => 0
|
110
|
-
}
|
111
|
-
}
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'return coveralls required structure' do
|
115
|
-
expect(branch_coverage_parsed).to eq [12, 0, 1, 1, 12, 0, 2, 0]
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe '#short_filename' do
|
120
|
-
subject { described_class.new.short_filename(filename) }
|
121
|
-
|
122
|
-
let(:filename) { '/app/app/controllers/application_controller.rb' }
|
123
|
-
|
124
|
-
before do
|
125
|
-
allow(SimpleCov).to receive(:root).and_return(root_path)
|
126
|
-
end
|
127
|
-
|
128
|
-
context 'with nil root path' do
|
129
|
-
let(:root_path) { nil }
|
130
|
-
|
131
|
-
it { is_expected.to eql filename }
|
132
|
-
end
|
133
|
-
|
134
|
-
context 'with multiple matches of root path' do
|
135
|
-
let(:root_path) { '/app' }
|
136
|
-
|
137
|
-
it { is_expected.to eql 'app/controllers/application_controller.rb' }
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'simplecov'
|
4
|
-
require 'webmock'
|
5
|
-
require 'vcr'
|
6
|
-
|
7
|
-
class InceptionFormatter
|
8
|
-
def format(result)
|
9
|
-
Coveralls::SimpleCov::Formatter.new.format(result)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def setup_formatter
|
14
|
-
if ENV['GITHUB_ACTIONS']
|
15
|
-
require 'simplecov-lcov'
|
16
|
-
|
17
|
-
SimpleCov::Formatter::LcovFormatter.config do |c|
|
18
|
-
c.report_with_single_file = true
|
19
|
-
c.single_report_path = 'coverage/lcov.info'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
SimpleCov.formatter =
|
24
|
-
if ENV['CI'] || ENV['COVERALLS_REPO_TOKEN']
|
25
|
-
if ENV['GITHUB_ACTIONS']
|
26
|
-
SimpleCov::Formatter::MultiFormatter.new([InceptionFormatter, SimpleCov::Formatter::LcovFormatter])
|
27
|
-
else
|
28
|
-
InceptionFormatter
|
29
|
-
end
|
30
|
-
else
|
31
|
-
SimpleCov::Formatter::HTMLFormatter
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
setup_formatter
|
36
|
-
|
37
|
-
SimpleCov.start do
|
38
|
-
add_filter do |source_file|
|
39
|
-
source_file.filename.include?('spec') && !source_file.filename.include?('fixture')
|
40
|
-
end
|
41
|
-
add_filter %r{/.bundle/}
|
42
|
-
end
|
43
|
-
|
44
|
-
# Leave this require after SimpleCov.start
|
45
|
-
require 'coveralls'
|
46
|
-
|
47
|
-
VCR.configure do |c|
|
48
|
-
c.cassette_library_dir = 'fixtures/vcr_cassettes'
|
49
|
-
c.hook_into :webmock
|
50
|
-
end
|
51
|
-
|
52
|
-
RSpec.configure do |config|
|
53
|
-
config.run_all_when_everything_filtered = true
|
54
|
-
config.filter_run :focus
|
55
|
-
config.include WebMock::API
|
56
|
-
|
57
|
-
config.after(:suite) do
|
58
|
-
setup_formatter
|
59
|
-
WebMock.disable!
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def stub_api_post
|
64
|
-
body = '{"message":"","url":""}'
|
65
|
-
stub_request(:post, "#{Coveralls::API::API_BASE}/jobs")
|
66
|
-
.to_return(status: 200, body: body, headers: {})
|
67
|
-
end
|
68
|
-
|
69
|
-
def silence(&block)
|
70
|
-
return yield if ENV['silence'] == 'false'
|
71
|
-
|
72
|
-
silence_stream($stdout, &block)
|
73
|
-
end
|
74
|
-
|
75
|
-
def silence_stream(stream)
|
76
|
-
old_stream = stream.dup
|
77
|
-
stream.reopen(IO::NULL)
|
78
|
-
stream.sync = true
|
79
|
-
yield
|
80
|
-
ensure
|
81
|
-
stream.reopen(old_stream)
|
82
|
-
old_stream.close
|
83
|
-
end
|