coveralls-ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/stale.yml +60 -0
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +22 -0
- data/CHANGELOG.md +21 -0
- data/Gemfile +41 -0
- data/LICENSE +22 -0
- data/README.md +6 -0
- data/Rakefile +14 -0
- data/bin/coveralls +9 -0
- data/coveralls-ruby.gemspec +32 -0
- data/lib/coveralls.rb +101 -0
- data/lib/coveralls/api.rb +128 -0
- data/lib/coveralls/command.rb +69 -0
- data/lib/coveralls/configuration.rb +234 -0
- data/lib/coveralls/output.rb +114 -0
- data/lib/coveralls/rake/task.rb +19 -0
- data/lib/coveralls/simplecov.rb +101 -0
- data/lib/coveralls/version.rb +3 -0
- data/spec/coveralls/configuration_spec.rb +371 -0
- data/spec/coveralls/coveralls_spec.rb +106 -0
- data/spec/coveralls/fixtures/app/controllers/sample.rb +12 -0
- data/spec/coveralls/fixtures/app/models/airplane.rb +10 -0
- data/spec/coveralls/fixtures/app/models/dog.rb +10 -0
- data/spec/coveralls/fixtures/app/models/house.rb +10 -0
- data/spec/coveralls/fixtures/app/models/robot.rb +10 -0
- data/spec/coveralls/fixtures/app/models/user.rb +10 -0
- data/spec/coveralls/fixtures/app/vendor/vendored_gem.rb +1 -0
- data/spec/coveralls/fixtures/sample.rb +12 -0
- data/spec/coveralls/output_spec.rb +92 -0
- data/spec/coveralls/simplecov_spec.rb +82 -0
- data/spec/spec_helper.rb +82 -0
- metadata +190 -0
@@ -0,0 +1 @@
|
|
1
|
+
# this file should not be covered
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Coveralls::Output do
|
4
|
+
it "defaults the IO to $stdout" do
|
5
|
+
old_stdout = $stdout
|
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
|
11
|
+
end
|
12
|
+
|
13
|
+
it "accepts an IO injection" do
|
14
|
+
out = StringIO.new
|
15
|
+
Coveralls::Output.output = out
|
16
|
+
Coveralls::Output.puts "this is a test"
|
17
|
+
expect(out.string).to eq "this is a test\n"
|
18
|
+
end
|
19
|
+
|
20
|
+
describe ".puts" do
|
21
|
+
it "accepts an IO injection" do
|
22
|
+
out = StringIO.new
|
23
|
+
Coveralls::Output.puts "this is a test", :output => out
|
24
|
+
expect(out.string).to eq "this is a test\n"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe ".print" do
|
29
|
+
it "accepts an IO injection" do
|
30
|
+
out = StringIO.new
|
31
|
+
Coveralls::Output.print "this is a test", :output => out
|
32
|
+
expect(out.string).to eq "this is a test"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'when silenced' do
|
37
|
+
before do
|
38
|
+
@original_stdout = $stdout
|
39
|
+
@output = StringIO.new
|
40
|
+
Coveralls::Output.silent = true
|
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 == ""
|
52
|
+
end
|
53
|
+
after do
|
54
|
+
$stdout = @original_stdout
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '.format' do
|
59
|
+
it "accepts a color argument" do
|
60
|
+
require 'term/ansicolor'
|
61
|
+
string = 'Hello'
|
62
|
+
ansi_color_string = Term::ANSIColor.red(string)
|
63
|
+
Coveralls::Output.format(string, :color => 'red').should eq(ansi_color_string)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "also accepts no color arguments" do
|
67
|
+
unformatted_string = "Hi Doggie!"
|
68
|
+
Coveralls::Output.format(unformatted_string).should eq(unformatted_string)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "rejects formats unrecognized by Term::ANSIColor" do
|
72
|
+
string = 'Hi dog!'
|
73
|
+
Coveralls::Output.format(string, :color => "not_a_real_color").should eq(string)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "accepts more than 1 color argument" do
|
77
|
+
string = 'Hi dog!'
|
78
|
+
multi_formatted_string = Term::ANSIColor.red{ Term::ANSIColor.underline(string) }
|
79
|
+
Coveralls::Output.format(string, :color => 'red underline').should eq(multi_formatted_string)
|
80
|
+
end
|
81
|
+
|
82
|
+
context "no color" do
|
83
|
+
before { Coveralls::Output.no_color = true }
|
84
|
+
|
85
|
+
it "does not add color to string" do
|
86
|
+
unformatted_string = "Hi Doggie!"
|
87
|
+
Coveralls::Output.format(unformatted_string, :color => 'red').
|
88
|
+
should eq(unformatted_string)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,82 @@
|
|
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", :if => RUBY_VERSION >= "1.9" 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
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'webmock'
|
3
|
+
require 'vcr'
|
4
|
+
|
5
|
+
require 'pry' if RUBY_VERSION > "1.8.7"
|
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
|
+
SimpleCov.formatter = if ENV['TRAVIS'] || ENV['COVERALLS_REPO_TOKEN']
|
15
|
+
InceptionFormatter
|
16
|
+
else
|
17
|
+
SimpleCov::Formatter::HTMLFormatter
|
18
|
+
end
|
19
|
+
|
20
|
+
# SimpleCov.start 'test_frameworks'
|
21
|
+
SimpleCov.start do
|
22
|
+
add_filter do |source_file|
|
23
|
+
source_file.filename =~ /spec/ && !(source_file.filename =~ /fixture/)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
setup_formatter
|
29
|
+
|
30
|
+
require 'coveralls'
|
31
|
+
|
32
|
+
VCR.configure do |c|
|
33
|
+
c.cassette_library_dir = 'fixtures/vcr_cassettes'
|
34
|
+
c.hook_into :webmock
|
35
|
+
end
|
36
|
+
|
37
|
+
RSpec.configure do |config|
|
38
|
+
config.run_all_when_everything_filtered = true
|
39
|
+
config.filter_run :focus
|
40
|
+
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
|
+
config.after(:suite) do
|
48
|
+
WebMock.disable!
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def stub_api_post
|
53
|
+
body = "{\"message\":\"\",\"url\":\"\"}"
|
54
|
+
stub_request(:post, Coveralls::API::API_BASE+"/jobs").with(
|
55
|
+
:headers => {
|
56
|
+
'Accept'=>'*/*; q=0.5, application/xml',
|
57
|
+
'Accept-Encoding'=>'gzip, deflate',
|
58
|
+
'Content-Length'=>/.+/,
|
59
|
+
'Content-Type'=>/.+/,
|
60
|
+
'User-Agent'=>'Ruby'
|
61
|
+
}
|
62
|
+
).to_return(:status => 200, :body => body, :headers => {})
|
63
|
+
end
|
64
|
+
|
65
|
+
def silence
|
66
|
+
return yield if ENV['silence'] == 'false'
|
67
|
+
|
68
|
+
silence_stream(STDOUT) do
|
69
|
+
yield
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
module Kernel
|
74
|
+
def silence_stream(stream)
|
75
|
+
old_stream = stream.dup
|
76
|
+
stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
|
77
|
+
stream.sync = true
|
78
|
+
yield
|
79
|
+
ensure
|
80
|
+
stream.reopen(old_stream)
|
81
|
+
end
|
82
|
+
end
|
metadata
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coveralls-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick Merwin
|
8
|
+
- Wil Gieseler
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2021-03-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: json
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.8'
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '3'
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '1.8'
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3'
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: simplecov
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.16.1
|
41
|
+
type: :runtime
|
42
|
+
prerelease: false
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.16.1
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: tins
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.6'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: term-ansicolor
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
type: :runtime
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.3'
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: thor
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.19.4
|
83
|
+
- - "<"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '2.0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 0.19.4
|
93
|
+
- - "<"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '2.0'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: bundler
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '2.0'
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.0'
|
110
|
+
description: A Ruby implementation of the Coveralls API.
|
111
|
+
email:
|
112
|
+
- nick@lemurheavy.com
|
113
|
+
- supapuerco@gmail.com
|
114
|
+
executables:
|
115
|
+
- coveralls
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".github/stale.yml"
|
120
|
+
- ".gitignore"
|
121
|
+
- ".rspec"
|
122
|
+
- ".ruby-version"
|
123
|
+
- ".travis.yml"
|
124
|
+
- CHANGELOG.md
|
125
|
+
- Gemfile
|
126
|
+
- LICENSE
|
127
|
+
- README.md
|
128
|
+
- Rakefile
|
129
|
+
- bin/coveralls
|
130
|
+
- coveralls-ruby.gemspec
|
131
|
+
- lib/coveralls.rb
|
132
|
+
- lib/coveralls/api.rb
|
133
|
+
- lib/coveralls/command.rb
|
134
|
+
- lib/coveralls/configuration.rb
|
135
|
+
- lib/coveralls/output.rb
|
136
|
+
- lib/coveralls/rake/task.rb
|
137
|
+
- lib/coveralls/simplecov.rb
|
138
|
+
- lib/coveralls/version.rb
|
139
|
+
- spec/coveralls/configuration_spec.rb
|
140
|
+
- spec/coveralls/coveralls_spec.rb
|
141
|
+
- spec/coveralls/fixtures/app/controllers/sample.rb
|
142
|
+
- spec/coveralls/fixtures/app/models/airplane.rb
|
143
|
+
- spec/coveralls/fixtures/app/models/dog.rb
|
144
|
+
- spec/coveralls/fixtures/app/models/house.rb
|
145
|
+
- spec/coveralls/fixtures/app/models/robot.rb
|
146
|
+
- spec/coveralls/fixtures/app/models/user.rb
|
147
|
+
- spec/coveralls/fixtures/app/vendor/vendored_gem.rb
|
148
|
+
- spec/coveralls/fixtures/sample.rb
|
149
|
+
- spec/coveralls/output_spec.rb
|
150
|
+
- spec/coveralls/simplecov_spec.rb
|
151
|
+
- spec/spec_helper.rb
|
152
|
+
homepage: https://coveralls.io
|
153
|
+
licenses:
|
154
|
+
- MIT
|
155
|
+
metadata:
|
156
|
+
homepage_uri: https://coveralls.io
|
157
|
+
source_code_uri: https://github.com/graphql-devise/coveralls-ruby
|
158
|
+
post_install_message:
|
159
|
+
rdoc_options: []
|
160
|
+
require_paths:
|
161
|
+
- lib
|
162
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 1.8.7
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - ">="
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
172
|
+
requirements: []
|
173
|
+
rubygems_version: 3.0.3
|
174
|
+
signing_key:
|
175
|
+
specification_version: 4
|
176
|
+
summary: A Ruby implementation of the Coveralls API.
|
177
|
+
test_files:
|
178
|
+
- spec/coveralls/configuration_spec.rb
|
179
|
+
- spec/coveralls/coveralls_spec.rb
|
180
|
+
- spec/coveralls/fixtures/app/controllers/sample.rb
|
181
|
+
- spec/coveralls/fixtures/app/models/airplane.rb
|
182
|
+
- spec/coveralls/fixtures/app/models/dog.rb
|
183
|
+
- spec/coveralls/fixtures/app/models/house.rb
|
184
|
+
- spec/coveralls/fixtures/app/models/robot.rb
|
185
|
+
- spec/coveralls/fixtures/app/models/user.rb
|
186
|
+
- spec/coveralls/fixtures/app/vendor/vendored_gem.rb
|
187
|
+
- spec/coveralls/fixtures/sample.rb
|
188
|
+
- spec/coveralls/output_spec.rb
|
189
|
+
- spec/coveralls/simplecov_spec.rb
|
190
|
+
- spec/spec_helper.rb
|