test_dots 0.1.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 +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/README.md +86 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/examples/minitest/Gemfile +6 -0
- data/examples/minitest/Gemfile.lock +21 -0
- data/examples/minitest/Rakefile +6 -0
- data/examples/minitest/test/features/feature_example_test.rb +11 -0
- data/examples/minitest/test/test_helper.rb +8 -0
- data/examples/minitest/test/units/unit_example_test.rb +11 -0
- data/examples/minitest_specs/Gemfile +5 -0
- data/examples/minitest_specs/Gemfile.lock +19 -0
- data/examples/minitest_specs/example_test.rb +20 -0
- data/examples/rspec/Gemfile +5 -0
- data/examples/rspec/Gemfile.lock +32 -0
- data/examples/rspec/spec/features/feature_example_spec.rb +11 -0
- data/examples/rspec/spec/spec_helper.rb +10 -0
- data/examples/rspec/spec/units/unit_example_spec.rb +11 -0
- data/examples/rspec_custom_adapter/Gemfile +5 -0
- data/examples/rspec_custom_adapter/Gemfile.lock +32 -0
- data/examples/rspec_custom_adapter/example_spec.rb +37 -0
- data/examples/rspec_full/Gemfile +5 -0
- data/examples/rspec_full/Gemfile.lock +32 -0
- data/examples/rspec_full/example_spec.rb +57 -0
- data/lib/minitest/test_dots_plugin.rb +66 -0
- data/lib/test_dots/api.rb +20 -0
- data/lib/test_dots/ci_adapters/base.rb +21 -0
- data/lib/test_dots/ci_adapters/circle_ci.rb +21 -0
- data/lib/test_dots/ci_adapters/jenkins.rb +21 -0
- data/lib/test_dots/ci_adapters/travis_ci.rb +17 -0
- data/lib/test_dots/configuration.rb +31 -0
- data/lib/test_dots/rspec_listener.rb +68 -0
- data/lib/test_dots/version.rb +3 -0
- data/lib/test_dots.rb +43 -0
- data/resources/cacert.pem +3646 -0
- data/test_dots.gemspec +29 -0
- metadata +151 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
module TestDots
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :enabled, :server, :port, :api_key, :endpoint, :use_ssl, :cacert_path, :ci_adapter
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@enabled = true
|
7
|
+
@server = ENV.fetch('TEST_DOTS_SERVER', 'testdots.com')
|
8
|
+
@port = port = ENV.fetch('TEST_DOTS_PORT', '443')
|
9
|
+
@api_key = ENV.fetch('TEST_DOTS_KEY', nil)
|
10
|
+
@endpoint = ENV.fetch('TEST_DOTS_ENDPOINT', '/api/v1/builds')
|
11
|
+
@use_ssl = true
|
12
|
+
@cacert_path = File.expand_path(File.join('..', '..', '..', 'resources', 'cacert.pem'), __FILE__)
|
13
|
+
@ci_adapter = default_ci_adapter
|
14
|
+
end
|
15
|
+
|
16
|
+
def collect_test_data?
|
17
|
+
enabled && api_key
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def default_ci_adapter
|
23
|
+
[
|
24
|
+
TestDots::CIAdapters::TravisCI.new,
|
25
|
+
TestDots::CIAdapters::Jenkins.new,
|
26
|
+
TestDots::CIAdapters::CircleCI.new,
|
27
|
+
TestDots::CIAdapters::Base.new
|
28
|
+
].find {|a| a.active?}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module TestDots
|
2
|
+
class RSpecListener
|
3
|
+
def self.register
|
4
|
+
RSpec.configure do |config|
|
5
|
+
methods = [
|
6
|
+
:dump_summary,
|
7
|
+
:example_passed,
|
8
|
+
:example_pending,
|
9
|
+
:example_failed,
|
10
|
+
:close
|
11
|
+
]
|
12
|
+
config.reporter.register_listener self.new, *methods
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@results = []
|
18
|
+
@dir = Pathname.new(Dir.pwd)
|
19
|
+
end
|
20
|
+
|
21
|
+
def close(_)
|
22
|
+
attributes = TestDots.send_report(
|
23
|
+
framework: 'rspec',
|
24
|
+
load_time: @load_time,
|
25
|
+
run_time: @run_time,
|
26
|
+
results: @results
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def dump_summary(summary_notification)
|
31
|
+
@load_time = summary_notification.load_time
|
32
|
+
@run_time = summary_notification.duration
|
33
|
+
end
|
34
|
+
|
35
|
+
def example_pending(notification)
|
36
|
+
example_finished(notification)
|
37
|
+
end
|
38
|
+
|
39
|
+
def example_passed(notification)
|
40
|
+
example_finished(notification)
|
41
|
+
end
|
42
|
+
|
43
|
+
def example_failed(notification)
|
44
|
+
example_finished(notification)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def example_finished(example_notification)
|
50
|
+
example = example_notification.example
|
51
|
+
execution_result = example.execution_result
|
52
|
+
|
53
|
+
@results << {
|
54
|
+
description: example.description,
|
55
|
+
full_description: example.full_description,
|
56
|
+
location: relative_path(example.location),
|
57
|
+
run_time: execution_result.run_time,
|
58
|
+
status: execution_result.status
|
59
|
+
}
|
60
|
+
nil
|
61
|
+
end
|
62
|
+
|
63
|
+
def relative_path(test_path)
|
64
|
+
expaned_test_path = File.expand_path(test_path, @dir)
|
65
|
+
Pathname.new(expaned_test_path).relative_path_from(@dir).to_s
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/test_dots.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'json'
|
2
|
+
require "net/http"
|
3
|
+
|
4
|
+
require "test_dots/version"
|
5
|
+
require "test_dots/configuration"
|
6
|
+
require "test_dots/api"
|
7
|
+
|
8
|
+
require "test_dots/ci_adapters/base"
|
9
|
+
require "test_dots/ci_adapters/travis_ci"
|
10
|
+
require "test_dots/ci_adapters/jenkins"
|
11
|
+
require "test_dots/ci_adapters/circle_ci"
|
12
|
+
|
13
|
+
module TestDots
|
14
|
+
def self.configuration
|
15
|
+
@configuration ||= Configuration.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.register_rspec_listener
|
19
|
+
if configuration.collect_test_data?
|
20
|
+
require 'test_dots/rspec_listener'
|
21
|
+
TestDots::RSpecListener.register
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.configure
|
26
|
+
yield(configuration)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.send_report(attributes)
|
30
|
+
ci_adapter = configuration.ci_adapter
|
31
|
+
api = TestDots::Api.new
|
32
|
+
|
33
|
+
attributes = attributes.merge(
|
34
|
+
gem_version: TestDots::VERSION,
|
35
|
+
ci_adapter: ci_adapter.class.to_s,
|
36
|
+
url: ci_adapter.url,
|
37
|
+
build: ci_adapter.build,
|
38
|
+
branch: ci_adapter.branch,
|
39
|
+
)
|
40
|
+
|
41
|
+
api.post(attributes.to_json)
|
42
|
+
end
|
43
|
+
end
|