rspeckled 0.0.42 → 0.0.43
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
- checksums.yaml.gz.sig +0 -0
- data/lib/rspeckled/reporting/example.rb +101 -0
- data/lib/rspeckled/reporting/outputs/csv.rb +41 -0
- data/lib/rspeckled/reporting/outputs/text.rb +39 -0
- data/lib/rspeckled/reporting/runner.rb +76 -0
- data/lib/rspeckled/reporting.rb +6 -0
- data/lib/rspeckled/spec_helpers/rspeckled.rb +1 -0
- data/lib/rspeckled/support.rb +7 -0
- data/lib/rspeckled/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +7 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6e5d300b5c651540f35e47cd75b444aa8045c3e
|
4
|
+
data.tar.gz: c6f152d7d477bb87bae569e1e72004573c8d3430
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d815ce7792064fa3f0f7f6e0e8ce3ab73cadc66873cb3f09232ad6c3ff41fedf9274d8421e2d9f7741ecc15d43a906772459ea07220196f2df0e53eb7240108
|
7
|
+
data.tar.gz: 15812a30b93a864d6d2d7ff964e91e51154b031e19e717e757aa95a1df30e413dad40a2c63b50e96014f4e1ea77aaa41002fe8bce128ae89b8212ca5a15297f9
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rspeckled
|
4
|
+
module Reporting
|
5
|
+
class Example
|
6
|
+
IGNORED_QUERIES_PATTERN = %r{
|
7
|
+
(
|
8
|
+
pg_table|
|
9
|
+
pg_attribute|
|
10
|
+
pg_namespace|
|
11
|
+
show\stables|
|
12
|
+
pragma|
|
13
|
+
sqlite_master/rollback|
|
14
|
+
^TRUNCATE TABLE|
|
15
|
+
^ALTER TABLE|
|
16
|
+
^BEGIN|
|
17
|
+
^COMMIT|
|
18
|
+
^ROLLBACK|
|
19
|
+
^RELEASE|
|
20
|
+
^SAVEPOINT
|
21
|
+
)
|
22
|
+
}xi
|
23
|
+
|
24
|
+
attr_accessor :counts,
|
25
|
+
:example
|
26
|
+
|
27
|
+
def initialize(example)
|
28
|
+
self.counts = Hash.new(0)
|
29
|
+
self.example = example
|
30
|
+
end
|
31
|
+
|
32
|
+
def file
|
33
|
+
metadata[:file_path]
|
34
|
+
end
|
35
|
+
|
36
|
+
def line_number
|
37
|
+
metadata[:line_number]
|
38
|
+
end
|
39
|
+
|
40
|
+
def status
|
41
|
+
execution_result.status
|
42
|
+
end
|
43
|
+
|
44
|
+
def time
|
45
|
+
execution_result.run_time
|
46
|
+
end
|
47
|
+
|
48
|
+
def description
|
49
|
+
metadata[:full_description]
|
50
|
+
end
|
51
|
+
|
52
|
+
def exception
|
53
|
+
execution_result.exception
|
54
|
+
end
|
55
|
+
|
56
|
+
def query_count
|
57
|
+
counts[:query_count]
|
58
|
+
end
|
59
|
+
|
60
|
+
def query_time
|
61
|
+
counts[:query_time]
|
62
|
+
end
|
63
|
+
|
64
|
+
def request_count
|
65
|
+
counts[:request_count]
|
66
|
+
end
|
67
|
+
|
68
|
+
def request_time
|
69
|
+
counts[:request_time]
|
70
|
+
end
|
71
|
+
|
72
|
+
def log_query(query, start, finish)
|
73
|
+
return if query[:sql] =~ IGNORED_QUERIES_PATTERN
|
74
|
+
|
75
|
+
counts[:query_count] += 1
|
76
|
+
counts[:query_time] += (finish - start)
|
77
|
+
end
|
78
|
+
|
79
|
+
def log_request(_request, start, finish)
|
80
|
+
counts[:request_count] += 1
|
81
|
+
counts[:request_time] += (finish - start)
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def metadata
|
87
|
+
example.metadata
|
88
|
+
end
|
89
|
+
|
90
|
+
def execution_result
|
91
|
+
@execution_result ||= begin
|
92
|
+
if example.execution_result.is_a?(Hash)
|
93
|
+
OpenStruct.new(example.execution_result)
|
94
|
+
else
|
95
|
+
example.execution_result
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'csv'
|
4
|
+
|
5
|
+
module Rspeckled
|
6
|
+
module Reporting
|
7
|
+
module Outputs
|
8
|
+
class Csv
|
9
|
+
FIELDS = %w{
|
10
|
+
branch
|
11
|
+
commit_hash
|
12
|
+
date
|
13
|
+
file
|
14
|
+
line_number
|
15
|
+
status
|
16
|
+
exception
|
17
|
+
time
|
18
|
+
query_count
|
19
|
+
query_time
|
20
|
+
query_percentage
|
21
|
+
request_count
|
22
|
+
request_time
|
23
|
+
request_percentage
|
24
|
+
description
|
25
|
+
}.freeze
|
26
|
+
|
27
|
+
attr_accessor :output
|
28
|
+
|
29
|
+
def initialize
|
30
|
+
self.output = CSV.open('log/rspec_report.csv', 'a').tap { |csv| csv << FIELDS }
|
31
|
+
end
|
32
|
+
|
33
|
+
def insert(data)
|
34
|
+
output << FIELDS.map do |field|
|
35
|
+
data.fetch(field.to_sym)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rspeckled
|
4
|
+
module Reporting
|
5
|
+
module Outputs
|
6
|
+
class Text
|
7
|
+
FIELDS = {
|
8
|
+
:branch => '%-<branch>s',
|
9
|
+
:commit_hash => '%-8.8<commit_hash>s',
|
10
|
+
:date => '%-<date>s',
|
11
|
+
:file => '%-80.80<file>s',
|
12
|
+
:status => '%-7.7<status>s',
|
13
|
+
:time => '%7.4<time>f',
|
14
|
+
:query_count => '%3<query_count>d',
|
15
|
+
:query_time => '%7.4<query_time>f',
|
16
|
+
:query_percentage => '%5.2<query_percentage>f%%',
|
17
|
+
:request_count => '%3<request_count>d',
|
18
|
+
:request_time => '%7.4<request_time>f',
|
19
|
+
:request_percentage => '%5.2<request_percentage>f%%',
|
20
|
+
:description => '%-80.80<description>s',
|
21
|
+
}.freeze
|
22
|
+
|
23
|
+
attr_accessor :output
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
self.output = File.open('log/rspec_report.txt', 'a')
|
27
|
+
end
|
28
|
+
|
29
|
+
def insert(data)
|
30
|
+
data[:file] = data[:file].gsub(%r{^\./spec/}, './') + ':' + data[:line_number].to_s
|
31
|
+
|
32
|
+
format_string = FIELDS.values.join(' - ') + "\n"
|
33
|
+
|
34
|
+
output.printf(format_string, data)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rspeckled
|
4
|
+
module Reporting
|
5
|
+
class Runner
|
6
|
+
FIELDS = %w{
|
7
|
+
branch
|
8
|
+
commit_hash
|
9
|
+
date
|
10
|
+
file
|
11
|
+
line_number
|
12
|
+
status
|
13
|
+
exception
|
14
|
+
time
|
15
|
+
query_count
|
16
|
+
query_time
|
17
|
+
request_count
|
18
|
+
request_time
|
19
|
+
description
|
20
|
+
}.freeze
|
21
|
+
|
22
|
+
attr_accessor :example,
|
23
|
+
:outputters
|
24
|
+
|
25
|
+
def initialize(outputters: [
|
26
|
+
Rspeckled::Reporting::Outputs::Text,
|
27
|
+
Rspeckled::Reporting::Outputs::Csv,
|
28
|
+
])
|
29
|
+
|
30
|
+
self.outputters = outputters.map(&:new)
|
31
|
+
end
|
32
|
+
|
33
|
+
def start(_notification)
|
34
|
+
ActiveSupport::Notifications.subscribe('sql.active_record') do |_name, start, finish, _id, query|
|
35
|
+
example&.log_query(query, start, finish)
|
36
|
+
end
|
37
|
+
|
38
|
+
ActiveSupport::Notifications.subscribe('process_action.action_controller') do |_name, start, finish, _id, request|
|
39
|
+
example&.log_request(request, start, finish)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def example_started(notification)
|
44
|
+
self.example = Example.new(notification.example)
|
45
|
+
end
|
46
|
+
|
47
|
+
# rubocop:disable Metrics/AbcSize
|
48
|
+
def example_finished(_notification)
|
49
|
+
outputters.each do |outputter|
|
50
|
+
outputter.insert(
|
51
|
+
:branch => `git rev-parse --abbrev-ref HEAD`.chomp,
|
52
|
+
:commit_hash => `git rev-parse HEAD`.chomp,
|
53
|
+
:date => Time.parse(`git show -s --format=%ci HEAD`.chomp),
|
54
|
+
:file => example.file,
|
55
|
+
:line_number => example.line_number,
|
56
|
+
:description => example.description,
|
57
|
+
:status => example.status,
|
58
|
+
:exception => example.exception,
|
59
|
+
:time => example.time,
|
60
|
+
:query_count => example.query_count,
|
61
|
+
:query_time => example.query_time,
|
62
|
+
:query_percentage => example.query_time / example.time * 100.0,
|
63
|
+
:request_count => example.request_count,
|
64
|
+
:request_time => example.request_time,
|
65
|
+
:request_percentage => example.request_time / example.time * 100.0
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
# rubocop:enable Metrics/AbcSize
|
70
|
+
|
71
|
+
alias example_passed example_finished
|
72
|
+
alias example_pending example_finished
|
73
|
+
alias example_failed example_finished
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/rspeckled/support.rb
CHANGED
@@ -50,6 +50,13 @@ RSpec.configure do |config|
|
|
50
50
|
config.profile_examples = [(config.files_to_run.length * 0.1).to_i, 10].max
|
51
51
|
end
|
52
52
|
|
53
|
+
config.reporter.register_listener Rspeckled::Reporting::Runner.new,
|
54
|
+
:example_failed,
|
55
|
+
:example_passed,
|
56
|
+
:example_pending,
|
57
|
+
:example_started,
|
58
|
+
:start
|
59
|
+
|
53
60
|
##############################################################################
|
54
61
|
# FORMATTING
|
55
62
|
##############################################################################
|
data/lib/rspeckled/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspeckled
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.43
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thegranddesign
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
Y2GAoHKstmfIVhc4XHOPpmTd2o/C29O9oaRgjrkfQEhF/KvJ/PhoV5hvokzsCyI5
|
32
32
|
iUeXPfvrGD/itYIBCgk+fnzyQQ4QtE5hTQaWQ3o2
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2018-04-
|
34
|
+
date: 2018-04-17 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
@@ -144,6 +144,11 @@ files:
|
|
144
144
|
- lib/rspeckled/plugins/vcr.rb
|
145
145
|
- lib/rspeckled/plugins/webmock.rb
|
146
146
|
- lib/rspeckled/plugins/wisper.rb
|
147
|
+
- lib/rspeckled/reporting.rb
|
148
|
+
- lib/rspeckled/reporting/example.rb
|
149
|
+
- lib/rspeckled/reporting/outputs/csv.rb
|
150
|
+
- lib/rspeckled/reporting/outputs/text.rb
|
151
|
+
- lib/rspeckled/reporting/runner.rb
|
147
152
|
- lib/rspeckled/spec_helpers/active_record_basic.rb
|
148
153
|
- lib/rspeckled/spec_helpers/active_record_connection_setup.rb
|
149
154
|
- lib/rspeckled/spec_helpers/rails.rb
|
metadata.gz.sig
CHANGED
Binary file
|