rspec_tesults_formatter 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/rspec_tesults_formatter.rb +141 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 83149db68a1d4e042eb7fe5a7444335556f63674551077ee2efdf7656bc929dc
|
4
|
+
data.tar.gz: 42c5571f4b022868dcea17dfe7cae6aeca9512cdce9e0e7ce416ff666ce56f5f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0cf0686b23594023fde1b7efccc33033baedbb44e7a0671f7c2298d9eab0f63a767fc4f7f640b16d7ae502b321edddfb059795d0bacfab6a2d3bbda7d278d73f
|
7
|
+
data.tar.gz: 10e2c9404c95b5d7d0f82cbad5e022a26fec16a68de41629e4be0cdb390df588cc15a1ad8479db2c2f1dc6202f97dc2c7c98d5d03f1dcc6e9927adfa5dc09cf4
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'tesults'
|
2
|
+
|
3
|
+
class TesultsFormatter
|
4
|
+
RSpec::Core::Formatters.register self, :example_finished, :dump_summary
|
5
|
+
|
6
|
+
def filesForCase(suite, name)
|
7
|
+
files = []
|
8
|
+
if (@files == nil)
|
9
|
+
return files
|
10
|
+
end
|
11
|
+
path = File.join(@files, suite, name)
|
12
|
+
if (File.directory?(path) != true)
|
13
|
+
return files
|
14
|
+
else
|
15
|
+
Dir.foreach(path) do |filename|
|
16
|
+
next if filename == '.' or filename == '..' or filename == '.DS_Store'
|
17
|
+
files.push(File.join(path, filename))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
return files
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(output)
|
24
|
+
@output = output
|
25
|
+
|
26
|
+
# args
|
27
|
+
@disabled = true
|
28
|
+
begin
|
29
|
+
@target = RSpec.configuration.tesults_target
|
30
|
+
rescue
|
31
|
+
@target = nil
|
32
|
+
end
|
33
|
+
begin
|
34
|
+
@files = RSpec.configuration.tesults_files
|
35
|
+
rescue
|
36
|
+
@files = nil
|
37
|
+
end
|
38
|
+
begin
|
39
|
+
@buildName = RSpec.configuration.tesults_build_name
|
40
|
+
rescue
|
41
|
+
@buildName = nil
|
42
|
+
end
|
43
|
+
begin
|
44
|
+
@buildDesc = RSpec.configuration.tesults_build_desc
|
45
|
+
rescue
|
46
|
+
@buildDesc = nil
|
47
|
+
end
|
48
|
+
begin
|
49
|
+
@buildResult = RSpec.configuration.tesults_build_result
|
50
|
+
if (@buildResult != "pass" && @buildResult != "fail")
|
51
|
+
@buildResult = "unknown"
|
52
|
+
end
|
53
|
+
rescue
|
54
|
+
@buildResult = "unknown"
|
55
|
+
end
|
56
|
+
begin
|
57
|
+
@buildReason = RSpec.configuration.tesults_build_reason
|
58
|
+
rescue
|
59
|
+
@buildReason = nil
|
60
|
+
end
|
61
|
+
|
62
|
+
if (@target != nil)
|
63
|
+
@disabled = false
|
64
|
+
end
|
65
|
+
if (@disabled == true)
|
66
|
+
puts 'Tesults disabled. No target supplied.'
|
67
|
+
end
|
68
|
+
|
69
|
+
@data = {
|
70
|
+
:target => @target,
|
71
|
+
:results => {
|
72
|
+
:cases => []
|
73
|
+
}
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
def example_finished(notification)
|
78
|
+
if (@disabled == true)
|
79
|
+
return
|
80
|
+
end
|
81
|
+
example = notification.example
|
82
|
+
result = example.execution_result.status.to_s
|
83
|
+
if result == "passed"
|
84
|
+
result = "pass"
|
85
|
+
elsif result == "failed"
|
86
|
+
result = "fail"
|
87
|
+
else
|
88
|
+
result = "unknown"
|
89
|
+
end
|
90
|
+
|
91
|
+
name = example.description
|
92
|
+
desc = example.metadata[:example_group][:description]
|
93
|
+
suite = example.metadata[:example_group][:parent_example_group][:description]
|
94
|
+
reason = example.exception
|
95
|
+
|
96
|
+
if reason == nil
|
97
|
+
reason = ""
|
98
|
+
else
|
99
|
+
reason = reason.to_s
|
100
|
+
end
|
101
|
+
|
102
|
+
@data[:results][:cases].push({
|
103
|
+
:name => example.description,
|
104
|
+
:result => result,
|
105
|
+
:desc => desc,
|
106
|
+
:suite => suite,
|
107
|
+
:reason => reason,
|
108
|
+
:files => filesForCase(suite, example.description)
|
109
|
+
})
|
110
|
+
|
111
|
+
#@output.puts name + ": " + result
|
112
|
+
end
|
113
|
+
|
114
|
+
def dump_summary (message)
|
115
|
+
if (@disabled == true)
|
116
|
+
return
|
117
|
+
end
|
118
|
+
if (@buildName != nil && @buildResult != nil)
|
119
|
+
buildCase = {
|
120
|
+
:name => @buildName,
|
121
|
+
:suite => "[build]",
|
122
|
+
:result => @buildResult
|
123
|
+
}
|
124
|
+
if (@buildDesc != nil)
|
125
|
+
buildCase[:desc] = @buildDesc
|
126
|
+
end
|
127
|
+
if (@buildReason != nil)
|
128
|
+
buildCase[:reason] = @buildReason
|
129
|
+
end
|
130
|
+
buildCase[:files] = filesForCase("[build]", @buildName)
|
131
|
+
@data[:results][:cases].push(buildCase)
|
132
|
+
end
|
133
|
+
# Use this puts for debugging: puts(@data)
|
134
|
+
puts 'Uploading results to Tesults...'
|
135
|
+
res = Tesults.upload(@data)
|
136
|
+
puts 'Success: ' + (res[:success] ? "true" : "false")
|
137
|
+
puts 'Message: ' + res[:message]
|
138
|
+
puts 'Warnings: ' + res[:warnings].length.to_s
|
139
|
+
puts 'Errors: ' + res[:errors].length.to_s
|
140
|
+
end
|
141
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec_tesults_formatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ajeet Dhaliwal
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-05-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: tesults
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.1.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: tesults
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.1.0
|
41
|
+
description: RSpec Tesults Formatter makes it easy to push test results data to Tesults
|
42
|
+
from your RSpec tests.
|
43
|
+
email:
|
44
|
+
- help@tesults.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- lib/rspec_tesults_formatter.rb
|
50
|
+
homepage: https://www.tesults.com
|
51
|
+
licenses:
|
52
|
+
- MIT
|
53
|
+
metadata: {}
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 2.7.6
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: RSpec Tesults Formatter
|
74
|
+
test_files: []
|