scrutinizer-ocular 1.0.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.
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'scrutinizer/ocular/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "scrutinizer-ocular"
8
+ spec.version = Scrutinizer::Ocular::VERSION
9
+ spec.authors = ["Scrutinizer"]
10
+ spec.email = ["support@scrutinizer-ci.com"]
11
+ spec.summary = %q{Uploads code coverage data to scrutinizer-ci.com}
12
+ spec.description = %q{Simple gem that uploads coverage data from a CI server; also handles submissions from parallelized runs.}
13
+ spec.homepage = "https://scrutinizer-ci.com"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+
22
+ if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('1.9')
23
+ spec.add_dependency 'simplecov', '>= 0.7'
24
+ end
25
+
26
+ spec.add_runtime_dependency('jruby-openssl') if RUBY_PLATFORM == 'java'
27
+
28
+ spec.add_development_dependency 'bundler', '~> 1.6'
29
+ spec.add_development_dependency 'rake'
30
+ spec.add_development_dependency 'rspec'
31
+ end
@@ -0,0 +1,19 @@
1
+
2
+ require 'spec_helper'
3
+ require 'scrutinizer/ocular/api_client'
4
+
5
+ describe Scrutinizer::Ocular::ApiClient do
6
+
7
+ client = Scrutinizer::Ocular::ApiClient.new(
8
+ "https://scrutinizer-ci.com/api",
9
+ "g/scrutinizer-ci/scrutinizer",
10
+ "abcdef",
11
+ ["abc123", "def456"],
12
+ nil
13
+ )
14
+
15
+ it "uploads coverage data" do
16
+ client.upload("rb-cc", "abcdef")
17
+ end
18
+
19
+ end
@@ -0,0 +1,4 @@
1
+
2
+ def foo
3
+ puts 'Hello World'
4
+ end
@@ -0,0 +1,60 @@
1
+
2
+ require 'spec_helper'
3
+ require 'simplecov'
4
+ require 'scrutinizer/ocular/formatter'
5
+
6
+ describe 'Scrutinizer::Ocular::Formatter' do
7
+ def delete_coverage(coverage_file)
8
+ File.delete(coverage_file) if File.exists? coverage_file
9
+ end
10
+
11
+ def fixture_path(relative_path)
12
+ File.dirname(__FILE__) + '/fixtures/' + relative_path
13
+ end
14
+
15
+ let(:result) {
16
+ SimpleCov::Result.new({
17
+ fixture_path('foo.rb') => [nil, 2, 2, nil]
18
+ })
19
+ }
20
+
21
+ let(:coverage_file) {
22
+ '/tmp/local-formatter-cc.json'
23
+ }
24
+
25
+ before {
26
+ delete_coverage(coverage_file)
27
+ }
28
+
29
+ after {
30
+ delete_coverage(coverage_file)
31
+ }
32
+
33
+ describe "LocalOutputFormatter" do
34
+ it "writes coverage to local file" do
35
+ ENV['SCRUTINIZER_CC_FILE'] = coverage_file
36
+ formatter = Scrutinizer::Ocular::LocalOutputFormatter.new
37
+ formatter.format(result)
38
+
39
+ output = File.open(coverage_file, 'r') do |file|
40
+ file.read.to_s
41
+ end
42
+
43
+ output.should match(/^\[\{"name":"[^"]+\/foo\.rb","lines":\[null,2,2,null\]\}\]$/)
44
+ end
45
+ end
46
+
47
+ describe "UploadingFormatter" do
48
+ it "uploads code coverage" do
49
+ ENV['SCRUTINIZER_REPOSITORY'] = 'foo/bar/baz'
50
+ formatter = Scrutinizer::Ocular::UploadingFormatter.new
51
+ output = Scrutinizer::Ocular::MemorizedOutput.new
52
+ formatter.output = output
53
+ formatter.format(result)
54
+
55
+ output.output.should match(/Uploading code coverage/)
56
+ output.output.should match(/Failed/)
57
+ output.output.should match(/foo\/bar\/baz/)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,50 @@
1
+
2
+ require 'spec_helper'
3
+ require 'scrutinizer/ocular/repository_introspector'
4
+
5
+ describe Scrutinizer::Ocular::RepositoryIntrospector do
6
+
7
+ repo_dir = nil
8
+ introspector = nil
9
+
10
+ before do
11
+ repo_dir = "/tmp/repo-inspector-rb"
12
+
13
+ if Dir.exists? repo_dir
14
+ system("rm -rf " + repo_dir)
15
+ end
16
+
17
+ Dir.mkdir(repo_dir)
18
+ system("git init 1>/dev/null", :chdir => repo_dir)
19
+ introspector = Scrutinizer::Ocular::RepositoryIntrospector.new(repo_dir)
20
+ end
21
+
22
+ it "returns the current revision" do
23
+ system("echo 'foo' > " + repo_dir + "/foo && git add . && git commit -m 'Foo' 1>/dev/null", :chdir => repo_dir)
24
+ introspector.get_current_revision.should match(/^[a-f0-9]{40}$/)
25
+ end
26
+
27
+ it "returns the parents of the revision" do
28
+ system("echo 'foo' > " + repo_dir + "/foo && git add . && git commit -m 'Foo' 1>/dev/null", :chdir => repo_dir)
29
+ base_rev = introspector.get_current_revision
30
+ introspector.get_current_parents.should eql?([])
31
+
32
+ system("echo 'bar' > " + repo_dir + "/bar && git add . && git commit -m 'Bar' 1>/dev/null", :chdir => repo_dir)
33
+ introspector.get_current_parents.should eql?([base_rev])
34
+ end
35
+
36
+ it "returns the GitHub repository name" do
37
+ system("git remote add origin git@github.com:scrutinizer-ci/ocular.rb", :chdir => repo_dir)
38
+ introspector.get_repository_name.should eql?("g/scrutinizer-ci/ocular.rb")
39
+
40
+ system("git remote set-url origin git://github.com:scrutinizer-ci/ocular.rb", :chdir => repo_dir)
41
+ introspector.get_repository_name.should eql?("g/scrutinizer-ci/ocular.rb")
42
+ end
43
+
44
+ after do
45
+ unless repo_dir.nil?
46
+ system("rm -rf " + repo_dir)
47
+ end
48
+ end
49
+
50
+ end
@@ -0,0 +1,71 @@
1
+ require 'simplecov'
2
+
3
+ class LazyTestFormatter
4
+ def format(result)
5
+ require 'scrutinizer/ocular'
6
+
7
+ if Scrutinizer::Ocular.should_run?
8
+ Scrutinizer::Ocular.create_formatter.new.format(result)
9
+ end
10
+ end
11
+ end
12
+
13
+ ::SimpleCov.add_filter 'vendor'
14
+ ::SimpleCov.formatter = LazyTestFormatter
15
+ ::SimpleCov.start
16
+
17
+ RSpec.configure do |config|
18
+
19
+ config.filter_run :focus
20
+ config.run_all_when_everything_filtered = true
21
+
22
+ # Many RSpec users commonly either run the entire suite or an individual
23
+ # file, and it's useful to allow more verbose output when running an
24
+ # individual spec file.
25
+ if config.files_to_run.one?
26
+ # Use the documentation formatter for detailed output,
27
+ # unless a formatter has already been configured
28
+ # (e.g. via a command-line flag).
29
+ config.default_formatter = 'doc'
30
+ end
31
+
32
+ # Print the 10 slowest examples and example groups at the
33
+ # end of the spec run, to help surface which specs are running
34
+ # particularly slow.
35
+ config.profile_examples = nil
36
+
37
+ # Run specs in random order to surface order dependencies. If you find an
38
+ # order dependency and want to debug it, you can fix the order by providing
39
+ # the seed, which is printed after each run.
40
+ # --seed 1234
41
+ config.order = :random
42
+
43
+ # Seed global randomization in this process using the `--seed` CLI option.
44
+ # Setting this allows you to use `--seed` to deterministically reproduce
45
+ # test failures related to randomization by passing the same `--seed` value
46
+ # as the one that triggered the failure.
47
+ Kernel.srand config.seed
48
+
49
+ # rspec-expectations config goes here. You can use an alternate
50
+ # assertion/expectation library such as wrong or the stdlib/minitest
51
+ # assertions if you prefer.
52
+ config.expect_with :rspec do |expectations|
53
+ # Enable only the newer, non-monkey-patching expect syntax.
54
+ # For more details, see:
55
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
56
+ expectations.syntax = :should
57
+ end
58
+
59
+ # rspec-mocks config goes here. You can use an alternate test double
60
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
61
+ config.mock_with :rspec do |mocks|
62
+ # Enable only the newer, non-monkey-patching expect syntax.
63
+ # For more details, see:
64
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
65
+ mocks.syntax = :should
66
+
67
+ # Prevents you from mocking or stubbing a method that does not exist on
68
+ # a real object. This is generally recommended.
69
+ mocks.verify_partial_doubles = true
70
+ end
71
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scrutinizer-ocular
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.0
6
+ platform: ruby
7
+ authors:
8
+ - Scrutinizer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-07-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ type: :runtime
16
+ name: simplecov
17
+ version_requirements: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0.7'
23
+ requirement: !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ! '>='
27
+ - !ruby/object:Gem::Version
28
+ version: '0.7'
29
+ prerelease: false
30
+ - !ruby/object:Gem::Dependency
31
+ type: :development
32
+ name: bundler
33
+ version_requirements: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: '1.6'
39
+ requirement: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: '1.6'
45
+ prerelease: false
46
+ - !ruby/object:Gem::Dependency
47
+ type: :development
48
+ name: rake
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirement: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ prerelease: false
62
+ - !ruby/object:Gem::Dependency
63
+ type: :development
64
+ name: rspec
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirement: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ prerelease: false
78
+ description: Simple gem that uploads coverage data from a CI server; also handles
79
+ submissions from parallelized runs.
80
+ email:
81
+ - support@scrutinizer-ci.com
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - .gitignore
87
+ - .rspec
88
+ - Gemfile
89
+ - LICENSE.txt
90
+ - README.md
91
+ - Rakefile
92
+ - lib/scrutinizer/ocular.rb
93
+ - lib/scrutinizer/ocular/api_client.rb
94
+ - lib/scrutinizer/ocular/formatter.rb
95
+ - lib/scrutinizer/ocular/output.rb
96
+ - lib/scrutinizer/ocular/repository_introspector.rb
97
+ - lib/scrutinizer/ocular/version.rb
98
+ - res/cacert.pem
99
+ - scrutinizer-ocular.gemspec
100
+ - spec/scrutinizer/ocular/api_client_spec.rb
101
+ - spec/scrutinizer/ocular/fixtures/foo.rb
102
+ - spec/scrutinizer/ocular/formatter_spec.rb
103
+ - spec/scrutinizer/ocular/repository_introspector_spec.rb
104
+ - spec/spec_helper.rb
105
+ homepage: https://scrutinizer-ci.com
106
+ licenses:
107
+ - MIT
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 1.8.28
127
+ signing_key:
128
+ specification_version: 3
129
+ summary: Uploads code coverage data to scrutinizer-ci.com
130
+ test_files:
131
+ - spec/scrutinizer/ocular/api_client_spec.rb
132
+ - spec/scrutinizer/ocular/fixtures/foo.rb
133
+ - spec/scrutinizer/ocular/formatter_spec.rb
134
+ - spec/scrutinizer/ocular/repository_introspector_spec.rb
135
+ - spec/spec_helper.rb