coveralls_reborn 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +59 -0
- data/.travis.yml +9 -4
- data/Gemfile +17 -16
- data/LICENSE +17 -18
- data/README.md +7 -1
- data/Rakefile +9 -3
- data/bin/coveralls +2 -1
- data/coveralls-ruby.gemspec +15 -13
- data/lib/coveralls/api.rb +72 -68
- data/lib/coveralls/command.rb +28 -24
- data/lib/coveralls/configuration.rb +46 -52
- data/lib/coveralls/output.rb +12 -7
- data/lib/coveralls/rake/task.rb +7 -6
- data/lib/coveralls/simplecov.rb +34 -32
- data/lib/coveralls/version.rb +3 -1
- data/lib/coveralls.rb +43 -41
- data/spec/coveralls/configuration_spec.rb +212 -160
- data/spec/coveralls/coveralls_spec.rb +41 -46
- data/spec/coveralls/fixtures/app/controllers/sample.rb +2 -0
- data/spec/coveralls/fixtures/app/models/airplane.rb +4 -2
- data/spec/coveralls/output_spec.rb +38 -51
- data/spec/coveralls/simple_cov/formatter_spec.rb +82 -0
- data/spec/spec_helper.rb +15 -18
- metadata +21 -16
- data/spec/coveralls/simplecov_spec.rb +0 -82
@@ -1,106 +1,101 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Coveralls do
|
4
6
|
before do
|
5
|
-
SimpleCov.
|
7
|
+
allow(SimpleCov).to receive(:start)
|
6
8
|
stub_api_post
|
7
|
-
|
9
|
+
described_class.testing = true
|
8
10
|
end
|
9
11
|
|
10
|
-
describe
|
11
|
-
it
|
12
|
-
|
12
|
+
describe '#will_run?' do
|
13
|
+
it 'checks CI environemnt variables' do
|
14
|
+
expect(described_class).to be_will_run
|
13
15
|
end
|
14
16
|
|
15
|
-
context
|
17
|
+
context 'with CI disabled' do
|
16
18
|
before do
|
17
|
-
|
18
|
-
ENV['
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
Coveralls.testing = false
|
19
|
+
allow(ENV).to receive(:[])
|
20
|
+
allow(ENV).to receive(:[]).with('COVERALLS_RUN_LOCALLY').and_return(nil)
|
21
|
+
allow(ENV).to receive(:[]).with('CI').and_return(nil)
|
22
|
+
described_class.testing = false
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
ENV['COVERALLS_RUN_LOCALLY'] = @coveralls_run_locally
|
28
|
-
end
|
29
|
-
|
30
|
-
it "indicates no run" do
|
31
|
-
Coveralls.will_run?.should be_falsy
|
25
|
+
it 'indicates no run' do
|
26
|
+
expect(described_class).not_to be_will_run
|
32
27
|
end
|
33
28
|
end
|
34
29
|
end
|
35
30
|
|
36
|
-
describe
|
37
|
-
it
|
38
|
-
|
39
|
-
|
31
|
+
describe '#should_run?' do
|
32
|
+
it 'outputs to stdout when running locally' do
|
33
|
+
described_class.testing = false
|
34
|
+
described_class.run_locally = true
|
40
35
|
silence do
|
41
|
-
|
36
|
+
described_class.should_run?
|
42
37
|
end
|
43
38
|
end
|
44
39
|
end
|
45
40
|
|
46
|
-
describe
|
47
|
-
it
|
48
|
-
::SimpleCov.should_receive(:start)
|
41
|
+
describe '#wear!' do
|
42
|
+
it 'receives block' do
|
49
43
|
silence do
|
50
44
|
subject.wear! do
|
51
45
|
add_filter 's'
|
52
46
|
end
|
53
47
|
end
|
48
|
+
|
49
|
+
expect(::SimpleCov).to have_received(:start)
|
54
50
|
end
|
55
51
|
|
56
|
-
it
|
57
|
-
::SimpleCov.should_receive(:start).with 'test_frameworks'
|
52
|
+
it 'uses string' do
|
58
53
|
silence do
|
59
54
|
subject.wear! 'test_frameworks'
|
60
55
|
end
|
56
|
+
|
57
|
+
expect(::SimpleCov).to have_received(:start).with 'test_frameworks'
|
61
58
|
end
|
62
59
|
|
63
|
-
it
|
64
|
-
::SimpleCov.should_receive(:start).with no_args
|
60
|
+
it 'uses default' do
|
65
61
|
silence do
|
66
62
|
subject.wear!
|
67
63
|
end
|
68
|
-
|
64
|
+
|
65
|
+
expect(::SimpleCov).to have_received(:start).with no_args
|
66
|
+
expect(::SimpleCov.filters.map(&:filter_argument)).to include 'vendor'
|
69
67
|
end
|
70
68
|
end
|
71
69
|
|
72
|
-
describe
|
73
|
-
it
|
74
|
-
::SimpleCov.should_receive(:start).with 'rails'
|
70
|
+
describe '#wear_merged!' do
|
71
|
+
it 'sets formatter to NilFormatter' do
|
75
72
|
silence do
|
76
73
|
subject.wear_merged! 'rails' do
|
77
|
-
add_filter
|
74
|
+
add_filter '/spec/'
|
78
75
|
end
|
79
76
|
end
|
80
|
-
|
77
|
+
|
78
|
+
expect(::SimpleCov).to have_received(:start).with 'rails'
|
79
|
+
expect(::SimpleCov.formatter).to be Coveralls::NilFormatter
|
81
80
|
end
|
82
81
|
end
|
83
82
|
|
84
|
-
describe
|
85
|
-
it
|
83
|
+
describe '#push!' do
|
84
|
+
it 'sends existing test results' do
|
86
85
|
result = false
|
87
86
|
silence do
|
88
87
|
result = subject.push!
|
89
88
|
end
|
90
|
-
result.
|
89
|
+
expect(result).to be_truthy
|
91
90
|
end
|
92
91
|
end
|
93
92
|
|
94
|
-
describe
|
95
|
-
it
|
93
|
+
describe '#setup!' do
|
94
|
+
it 'sets SimpleCov adapter' do
|
96
95
|
SimpleCovTmp = SimpleCov
|
97
96
|
Object.send :remove_const, :SimpleCov
|
98
97
|
silence { subject.setup! }
|
99
98
|
SimpleCov = SimpleCovTmp
|
100
99
|
end
|
101
100
|
end
|
102
|
-
|
103
|
-
after(:all) do
|
104
|
-
setup_formatter
|
105
|
-
end
|
106
101
|
end
|
@@ -1,91 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Coveralls::Output do
|
4
|
-
it
|
5
|
-
|
6
|
-
out = StringIO.new
|
7
|
-
$stdout = out
|
8
|
-
Coveralls::Output.puts "this is a test"
|
9
|
-
expect(out.string).to eq "this is a test\n"
|
10
|
-
$stdout = old_stdout
|
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
|
11
8
|
end
|
12
9
|
|
13
|
-
it
|
10
|
+
it 'accepts an IO injection' do
|
14
11
|
out = StringIO.new
|
15
|
-
|
16
|
-
|
12
|
+
allow(described_class).to receive(:output).and_return(out)
|
13
|
+
described_class.puts 'this is a test'
|
17
14
|
expect(out.string).to eq "this is a test\n"
|
18
15
|
end
|
19
16
|
|
20
|
-
describe
|
21
|
-
it
|
17
|
+
describe '.puts' do
|
18
|
+
it 'accepts an IO injection' do
|
22
19
|
out = StringIO.new
|
23
|
-
|
20
|
+
described_class.puts 'this is a test', output: out
|
24
21
|
expect(out.string).to eq "this is a test\n"
|
25
22
|
end
|
26
23
|
end
|
27
24
|
|
28
|
-
describe
|
29
|
-
it
|
25
|
+
describe '.print' do
|
26
|
+
it 'accepts an IO injection' do
|
30
27
|
out = StringIO.new
|
31
|
-
|
32
|
-
expect(out.string).to eq
|
28
|
+
described_class.print 'this is a test', output: out
|
29
|
+
expect(out.string).to eq 'this is a test'
|
33
30
|
end
|
34
31
|
end
|
35
32
|
|
36
33
|
describe 'when silenced' do
|
37
|
-
before
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
$stdout = @output
|
42
|
-
end
|
43
|
-
it "should not puts" do
|
44
|
-
Coveralls::Output.puts "foo"
|
45
|
-
@output.rewind
|
46
|
-
@output.read.should == ""
|
47
|
-
end
|
48
|
-
it "should not print" do
|
49
|
-
Coveralls::Output.print "foo"
|
50
|
-
@output.rewind
|
51
|
-
@output.read.should == ""
|
34
|
+
before { described_class.silent = true }
|
35
|
+
|
36
|
+
it 'does not puts' do
|
37
|
+
expect { described_class.puts 'foo' }.not_to output("foo\n").to_stdout
|
52
38
|
end
|
53
|
-
|
54
|
-
|
39
|
+
|
40
|
+
it 'does not print' do
|
41
|
+
expect { described_class.print 'foo' }.not_to output('foo').to_stdout
|
55
42
|
end
|
56
43
|
end
|
57
44
|
|
58
45
|
describe '.format' do
|
59
|
-
it
|
46
|
+
it 'accepts a color argument' do
|
60
47
|
require 'term/ansicolor'
|
61
48
|
string = 'Hello'
|
62
|
-
ansi_color_string =
|
63
|
-
|
49
|
+
ansi_color_string = Term::ANSIColor.red(string)
|
50
|
+
expect(described_class.format(string, color: 'red')).to eq(ansi_color_string)
|
64
51
|
end
|
65
52
|
|
66
|
-
it
|
67
|
-
unformatted_string =
|
68
|
-
|
53
|
+
it 'also accepts no color arguments' do
|
54
|
+
unformatted_string = 'Hi Doggie!'
|
55
|
+
expect(described_class.format(unformatted_string)).to eq(unformatted_string)
|
69
56
|
end
|
70
57
|
|
71
|
-
it
|
58
|
+
it 'rejects formats unrecognized by Term::ANSIColor' do
|
72
59
|
string = 'Hi dog!'
|
73
|
-
|
60
|
+
expect(described_class.format(string, color: 'not_a_real_color')).to eq(string)
|
74
61
|
end
|
75
62
|
|
76
|
-
it
|
63
|
+
it 'accepts more than 1 color argument' do
|
77
64
|
string = 'Hi dog!'
|
78
|
-
multi_formatted_string = Term::ANSIColor.red{ Term::ANSIColor.underline(string) }
|
79
|
-
|
65
|
+
multi_formatted_string = Term::ANSIColor.red { Term::ANSIColor.underline(string) }
|
66
|
+
expect(described_class.format(string, color: 'red underline')).to eq(multi_formatted_string)
|
80
67
|
end
|
81
68
|
|
82
|
-
context
|
83
|
-
before {
|
69
|
+
context 'without color' do
|
70
|
+
before { described_class.no_color = true }
|
84
71
|
|
85
|
-
it
|
86
|
-
unformatted_string =
|
87
|
-
|
88
|
-
|
72
|
+
it 'does not add color to string' do
|
73
|
+
unformatted_string = 'Hi Doggie!'
|
74
|
+
expect(described_class.format(unformatted_string, color: 'red'))
|
75
|
+
.to eq(unformatted_string)
|
89
76
|
end
|
90
77
|
end
|
91
78
|
end
|
@@ -0,0 +1,82 @@
|
|
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
|
+
SimpleCov::Result.new(source_fixture('app/controllers/sample.rb') => [nil, 1, 1, 1, nil, 0, 1, 1, nil, nil],
|
16
|
+
source_fixture('app/models/airplane.rb') => [0, 0, 0, 0, 0],
|
17
|
+
source_fixture('app/models/dog.rb') => [1, 1, 1, 1, 1],
|
18
|
+
source_fixture('app/models/house.rb') => [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil],
|
19
|
+
source_fixture('app/models/robot.rb') => [1, 1, 1, 1, nil, nil, 1, 0, nil, nil],
|
20
|
+
source_fixture('app/models/user.rb') => [nil, 1, 1, 1, 1, 0, 1, 0, nil, nil],
|
21
|
+
source_fixture('sample.rb') => [nil, 1, 1, 1, nil, 0, 1, 1, nil, nil])
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#format' do
|
25
|
+
context 'when should run' do
|
26
|
+
before do
|
27
|
+
Coveralls.testing = true
|
28
|
+
Coveralls.noisy = false
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'posts json' do
|
32
|
+
expect(result.files).not_to be_empty
|
33
|
+
silence do
|
34
|
+
expect(described_class.new.format(result)).to be_truthy
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when should not run, noisy' do
|
40
|
+
it 'only displays result' do
|
41
|
+
silence do
|
42
|
+
expect(described_class.new.display_result(result)).to be_truthy
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'without files' do
|
48
|
+
let(:result) { SimpleCov::Result.new({}) }
|
49
|
+
|
50
|
+
it 'shows note that no files have been covered' do
|
51
|
+
Coveralls.noisy = true
|
52
|
+
Coveralls.testing = false
|
53
|
+
|
54
|
+
silence do
|
55
|
+
expect do
|
56
|
+
described_class.new.format(result)
|
57
|
+
end.not_to raise_error
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'with api error' do
|
63
|
+
it 'rescues' do
|
64
|
+
e = SocketError.new
|
65
|
+
|
66
|
+
silence do
|
67
|
+
expect(described_class.new.display_error(e)).to be_falsy
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#get_source_files' do
|
73
|
+
let(:source_files) { described_class.new.get_source_files(result) }
|
74
|
+
|
75
|
+
it 'nils the skipped lines' do
|
76
|
+
source_file = source_files.first
|
77
|
+
expect(source_file[:coverage]).not_to eq result.files.first.coverage
|
78
|
+
expect(source_file[:coverage]).to eq [nil, 1, 1, 1, nil, 0, 1, 1, nil, nil, nil, nil, nil]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'simplecov'
|
2
4
|
require 'webmock'
|
3
5
|
require 'vcr'
|
@@ -12,15 +14,15 @@ end
|
|
12
14
|
|
13
15
|
def setup_formatter
|
14
16
|
SimpleCov.formatter = if ENV['TRAVIS'] || ENV['COVERALLS_REPO_TOKEN']
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
InceptionFormatter
|
18
|
+
else
|
19
|
+
SimpleCov::Formatter::HTMLFormatter
|
20
|
+
end
|
19
21
|
|
20
22
|
# SimpleCov.start 'test_frameworks'
|
21
23
|
SimpleCov.start do
|
22
24
|
add_filter do |source_file|
|
23
|
-
source_file.filename =~ /spec/ &&
|
25
|
+
source_file.filename =~ /spec/ && source_file.filename !~ /fixture/
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
@@ -38,26 +40,21 @@ RSpec.configure do |config|
|
|
38
40
|
config.run_all_when_everything_filtered = true
|
39
41
|
config.filter_run :focus
|
40
42
|
config.include WebMock::API
|
41
|
-
config.expect_with :rspec do |c|
|
42
|
-
c.syntax = [:should, :expect]
|
43
|
-
end
|
44
|
-
config.mock_with :rspec do |c|
|
45
|
-
c.syntax = [:should, :expect]
|
46
|
-
end
|
47
43
|
config.after(:suite) do
|
44
|
+
setup_formatter
|
48
45
|
WebMock.disable!
|
49
46
|
end
|
50
47
|
end
|
51
48
|
|
52
49
|
def stub_api_post
|
53
|
-
body =
|
54
|
-
stub_request(:post, Coveralls::API::API_BASE+
|
50
|
+
body = '{"message":"","url":""}'
|
51
|
+
stub_request(:post, Coveralls::API::API_BASE + '/jobs').with(
|
55
52
|
headers: {
|
56
|
-
'Accept'=>'*/*; q=0.5, application/xml',
|
57
|
-
'Accept-Encoding'=>'gzip, deflate',
|
58
|
-
'Content-Length'
|
59
|
-
'Content-Type'
|
60
|
-
'User-Agent'=>'Ruby'
|
53
|
+
'Accept' => '*/*; q=0.5, application/xml',
|
54
|
+
'Accept-Encoding' => 'gzip, deflate',
|
55
|
+
'Content-Length' => /.+/,
|
56
|
+
'Content-Type' => /.+/,
|
57
|
+
'User-Agent' => 'Ruby'
|
61
58
|
}
|
62
59
|
).to_return(status: 200, body: body, headers: {})
|
63
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coveralls_reborn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Nick Merwin
|
8
|
+
- Wil Gieseler
|
7
9
|
- Geremia Taglialatela
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
|
-
date: 2017-
|
13
|
+
date: 2017-11-15 00:00:00.000000000 Z
|
12
14
|
dependencies:
|
13
15
|
- !ruby/object:Gem::Dependency
|
14
16
|
name: json
|
@@ -39,63 +41,65 @@ dependencies:
|
|
39
41
|
- !ruby/object:Gem::Version
|
40
42
|
version: 0.15.1
|
41
43
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
44
|
+
name: term-ansicolor
|
43
45
|
requirement: !ruby/object:Gem::Requirement
|
44
46
|
requirements:
|
45
47
|
- - "~>"
|
46
48
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
49
|
+
version: '1.3'
|
48
50
|
type: :runtime
|
49
51
|
prerelease: false
|
50
52
|
version_requirements: !ruby/object:Gem::Requirement
|
51
53
|
requirements:
|
52
54
|
- - "~>"
|
53
55
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1.
|
56
|
+
version: '1.3'
|
55
57
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
58
|
+
name: thor
|
57
59
|
requirement: !ruby/object:Gem::Requirement
|
58
60
|
requirements:
|
59
61
|
- - "~>"
|
60
62
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
63
|
+
version: 0.20.0
|
62
64
|
type: :runtime
|
63
65
|
prerelease: false
|
64
66
|
version_requirements: !ruby/object:Gem::Requirement
|
65
67
|
requirements:
|
66
68
|
- - "~>"
|
67
69
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
70
|
+
version: 0.20.0
|
69
71
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
72
|
+
name: tins
|
71
73
|
requirement: !ruby/object:Gem::Requirement
|
72
74
|
requirements:
|
73
75
|
- - "~>"
|
74
76
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
77
|
+
version: '1.6'
|
76
78
|
type: :runtime
|
77
79
|
prerelease: false
|
78
80
|
version_requirements: !ruby/object:Gem::Requirement
|
79
81
|
requirements:
|
80
82
|
- - "~>"
|
81
83
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
84
|
+
version: '1.6'
|
83
85
|
- !ruby/object:Gem::Dependency
|
84
86
|
name: bundler
|
85
87
|
requirement: !ruby/object:Gem::Requirement
|
86
88
|
requirements:
|
87
89
|
- - "~>"
|
88
90
|
- !ruby/object:Gem::Version
|
89
|
-
version: '1.
|
91
|
+
version: '1.16'
|
90
92
|
type: :development
|
91
93
|
prerelease: false
|
92
94
|
version_requirements: !ruby/object:Gem::Requirement
|
93
95
|
requirements:
|
94
96
|
- - "~>"
|
95
97
|
- !ruby/object:Gem::Version
|
96
|
-
version: '1.
|
98
|
+
version: '1.16'
|
97
99
|
description: A Ruby implementation of the Coveralls API.
|
98
100
|
email:
|
101
|
+
- nick@lemurheavy.com
|
102
|
+
- supapuerco@gmail.com
|
99
103
|
- tagliala.dev@gmail.com
|
100
104
|
executables:
|
101
105
|
- coveralls
|
@@ -104,6 +108,7 @@ extra_rdoc_files: []
|
|
104
108
|
files:
|
105
109
|
- ".gitignore"
|
106
110
|
- ".rspec"
|
111
|
+
- ".rubocop.yml"
|
107
112
|
- ".ruby-version"
|
108
113
|
- ".travis.yml"
|
109
114
|
- CHANGELOG.md
|
@@ -132,7 +137,7 @@ files:
|
|
132
137
|
- spec/coveralls/fixtures/app/vendor/vendored_gem.rb
|
133
138
|
- spec/coveralls/fixtures/sample.rb
|
134
139
|
- spec/coveralls/output_spec.rb
|
135
|
-
- spec/coveralls/
|
140
|
+
- spec/coveralls/simple_cov/formatter_spec.rb
|
136
141
|
- spec/spec_helper.rb
|
137
142
|
homepage: https://coveralls.io
|
138
143
|
licenses:
|
@@ -146,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
151
|
requirements:
|
147
152
|
- - ">="
|
148
153
|
- !ruby/object:Gem::Version
|
149
|
-
version: 1
|
154
|
+
version: '2.1'
|
150
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
156
|
requirements:
|
152
157
|
- - ">="
|
@@ -170,5 +175,5 @@ test_files:
|
|
170
175
|
- spec/coveralls/fixtures/app/vendor/vendored_gem.rb
|
171
176
|
- spec/coveralls/fixtures/sample.rb
|
172
177
|
- spec/coveralls/output_spec.rb
|
173
|
-
- spec/coveralls/
|
178
|
+
- spec/coveralls/simple_cov/formatter_spec.rb
|
174
179
|
- spec/spec_helper.rb
|
@@ -1,82 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Coveralls::SimpleCov::Formatter do
|
4
|
-
|
5
|
-
before do
|
6
|
-
stub_api_post
|
7
|
-
end
|
8
|
-
|
9
|
-
def source_fixture(filename)
|
10
|
-
File.expand_path( File.join( File.dirname( __FILE__ ), 'fixtures', filename ) )
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:result) {
|
14
|
-
|
15
|
-
SimpleCov::Result.new({
|
16
|
-
source_fixture( 'sample.rb' ) => [nil, 1, 1, 1, nil, 0, 1, 1, nil, nil],
|
17
|
-
source_fixture( 'app/models/user.rb' ) => [nil, 1, 1, 1, 1, 0, 1, 0, nil, nil],
|
18
|
-
source_fixture( 'app/models/robot.rb' ) => [1, 1, 1, 1, nil, nil, 1, 0, nil, nil],
|
19
|
-
source_fixture( 'app/models/house.rb' ) => [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil],
|
20
|
-
source_fixture( 'app/models/airplane.rb' ) => [0, 0, 0, 0, 0],
|
21
|
-
source_fixture( 'app/models/dog.rb' ) => [1, 1, 1, 1, 1],
|
22
|
-
source_fixture( 'app/controllers/sample.rb' ) => [nil, 1, 1, 1, nil, 0, 1, 1, nil, nil]
|
23
|
-
})
|
24
|
-
}
|
25
|
-
|
26
|
-
describe "#format" do
|
27
|
-
context "should run" do
|
28
|
-
before do
|
29
|
-
Coveralls.testing = true
|
30
|
-
Coveralls.noisy = false
|
31
|
-
end
|
32
|
-
|
33
|
-
it "posts json" do
|
34
|
-
result.files.should_not be_empty
|
35
|
-
silence do
|
36
|
-
Coveralls::SimpleCov::Formatter.new.format(result).should be_truthy
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context "should not run, noisy" do
|
42
|
-
it "only displays result" do
|
43
|
-
silence do
|
44
|
-
Coveralls::SimpleCov::Formatter.new.display_result(result).should be_truthy
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "no files" do
|
50
|
-
let(:result) { SimpleCov::Result.new({}) }
|
51
|
-
it "shows note that no files have been covered" do
|
52
|
-
Coveralls.noisy = true
|
53
|
-
Coveralls.testing = false
|
54
|
-
|
55
|
-
silence do
|
56
|
-
expect do
|
57
|
-
Coveralls::SimpleCov::Formatter.new.format(result)
|
58
|
-
end.not_to raise_error
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context "with api error" do
|
64
|
-
it "rescues" do
|
65
|
-
e = SocketError.new
|
66
|
-
|
67
|
-
silence do
|
68
|
-
Coveralls::SimpleCov::Formatter.new.display_error(e).should be_falsy
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context "#get_source_files" do
|
74
|
-
let(:source_files) { Coveralls::SimpleCov::Formatter.new.get_source_files(result) }
|
75
|
-
it "nils the skipped lines" do
|
76
|
-
source_file = source_files.first
|
77
|
-
source_file[:coverage].should_not eq result.files.first.coverage
|
78
|
-
source_file[:coverage].should eq [nil, 1, 1, 1, nil, 0, nil, nil, nil, nil, nil]
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|